Pin non-development startup refusal and no-CORS posture (#9) #56

Merged
amiryahaya merged 2 commits from test/9-startup-cors into main 2026-10-25 14:36:09 +01:00
Owner

Refs #9 (F04). Test-only; no production code changes.

An acceptance audit of the M1 issues found two small gaps against #9's criteria. This PR closes them:

  • startup_refuses_an_unset_or_non_development_environment runs the real rag-api binary with RAG_ENV unset, production, staging and empty. Each must exit non-zero with the "production identity startup" message, before any configuration or database access.
  • cross_origin_requests_get_no_cors_grant sends a preflight and an Origin GET to the public health router. Neither response may carry any access-control-* header.

Limits

  • The CORS test covers only the public health router. The identity, session and admin routers are assembled in main.rs and are not exercised, so a CORS layer added only there would not be caught. The test comment says this.
  • Both tests describe behaviour that already holds, so they pass on first run. I reasoned about, but did not mutation-test, whether they fail when the guards are removed.

Verification

  • cargo test -p rag-api --locked --test startup --test cors: 4 passed
  • cargo fmt and cargo clippy -p rag-api --all-targets -- -D warnings: clean
  • Coverage (bash scripts/coverage.sh rust): 93.61% line coverage (minimum 80%), unchanged
  • Reviews: complexity pass found one comment overstatement, fixed in 3facfd6; correctness pass found no Critical or Important issues

🤖 Generated with Claude Code

Refs #9 (F04). Test-only; no production code changes. An acceptance audit of the M1 issues found two small gaps against #9's criteria. This PR closes them: - `startup_refuses_an_unset_or_non_development_environment` runs the real `rag-api` binary with `RAG_ENV` unset, `production`, `staging` and empty. Each must exit non-zero with the "production identity startup" message, before any configuration or database access. - `cross_origin_requests_get_no_cors_grant` sends a preflight and an `Origin` GET to the public health router. Neither response may carry any `access-control-*` header. ## Limits - The CORS test covers only the public health router. The identity, session and admin routers are assembled in `main.rs` and are not exercised, so a CORS layer added only there would not be caught. The test comment says this. - Both tests describe behaviour that already holds, so they pass on first run. I reasoned about, but did not mutation-test, whether they fail when the guards are removed. ## Verification - `cargo test -p rag-api --locked --test startup --test cors`: 4 passed - `cargo fmt` and `cargo clippy -p rag-api --all-targets -- -D warnings`: clean - Coverage (`bash scripts/coverage.sh rust`): **93.61%** line coverage (minimum 80%), unchanged - Reviews: complexity pass found one comment overstatement, fixed in `3facfd6`; correctness pass found no Critical or Important issues 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Closes two gaps the F04 acceptance audit found: startup must refuse an
unset or non-development environment, and cross-origin requests must get
no access-control headers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test(api): state what the CORS test covers (#9)
All checks were successful
CI / Web checks (pull_request) Successful in 44s
CI / Web checks (push) Successful in 40s
CI / Rust checks (push) Successful in 16m7s
CI / Rust checks (pull_request) Successful in 29m41s
3facfd6f36
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.