The CORS defaults already ship correct (`["*"]`), but nothing guarded
the preflight contract. Add a regression test that sends an
`OPTIONS /api/decks/` preflight from the shipped dev origin
(`http://localhost:5173`) and asserts `POST`/`PUT` appear in
`Access-Control-Allow-Methods`, exercising the real
settings → lite-bootstrap → Starlette CORS middleware wiring.
Ported from modern-python/litestar-sqlalchemy-template#34. Verified it
fails (preflight 400, POST absent) if the methods default regresses to
`[""]`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Context
Ports the regression test from modern-python/litestar-sqlalchemy-template#34.
That PR fixed a CORS bug where the defaults were [""] (neither allow-all ["*"] nor empty []). In this template the settings.py defaults already ship correct:
…but there was no test guarding the preflight contract, so a future regression to [""] would slip through silently.
Change
Add tests/test_cors.py: a preflight OPTIONS /api/decks/ from the shipped dev origin (http://localhost:5173) with Access-Control-Request-Method: POST, asserting POST/PUT appear in Access-Control-Allow-Methods. Exercises the real settings → lite-bootstrap → Starlette CORSMiddleware wiring through the existing client fixture. No DB needed (preflight is handled in middleware before routing).
Verification
🤖 Generated with Claude Code