test(http): cover Origin validation matrix for MCP endpoint#1075
Conversation
Add regression tests for the shared Host/Origin validation path. A new origin_test.exs unit suite exercises the previously untested allowlist, Origin: null, and non-loopback fail-closed branches of PtcRunnerMcp.Http.Origin. A router-level test confirms GET /mcp with an invalid Origin returns 403 before the 405 method catch-all. No production code change; the behavioral fix already landed. Closes #1041 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR Review: test(http): cover Origin validation matrix for MCP endpointSummaryTest-only PR that fills a regression-coverage gap for What's Good
Issues (Must Fix)None. Suggestions (Optional)
SecurityNo concerns. This is the right kind of change for a DocumentationNo updates needed — test-only change, no public API or behavior change. VerdictApprove. Well-scoped, accurate, and consistent with existing test conventions. Note: CI must run the suite for final confirmation, as the dependencies were not installed in my review environment (I verified the assertions by tracing |
Auto-Triage Summary
No FIX_NOW items. Added |
Add regression tests for the shared Host/Origin validation path. A new origin_test.exs unit suite exercises the previously untested allowlist, Origin: null, and non-loopback fail-closed branches of PtcRunnerMcp.Http.Origin. A router-level test confirms GET /mcp with an invalid Origin returns 403 before the 405 method catch-all. No production code change; the behavioral fix already landed. Closes #1041
Summary
Regression test coverage for the shared Host/Origin validation path on the
/mcpHTTP endpoint. The behavioral fix (validation runs before methoddispatch for every method) already landed; this fills the test gap for the
security-critical Origin policy branches.
mcp_server/test/ptc_runner_mcp/http/origin_test.exsunit suite(mirrors
host_test.exs) exercising the previously untested branches ofPtcRunnerMcp.Http.Origin: theallowed_originsallowlist,Origin: nullrejection, and the non-loopback fail-closed path. Also covers header
extraction and the loopback default-allow branch for a coherent matrix.
http_router_test.exs:GET /mcpwith an invalidOrigin returns
403before the405method catch-all, complementing theexisting bad-Host GET test.
No production code change — testing confirmed the existing validation is
correct.
Test plan
mix test test/ptc_runner_mcp/http/origin_test.exs test/ptc_runner_mcp/http_router_test.exs(49 tests, 0 failures)mix precommitfull suite (653 tests, 0 failures)Closes #1041
🤖 Generated with Claude Code