forked from 0xWheatyz/SPARC
Add JWT auth tests: registration, login, protected routes, token refresh, admin endpoints #153
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The existing tests in
tests/test_api.pybypass authentication entirely. There is no test coverage for the JWT flow, meaning regressions in auth behaviour will go undetected.Work
httpx.AsyncClientand a test database fixture so tests are isolated.Acceptance Criteria
auth.pyincreases measurably.References
Roadmap: P1 — Test coverage for auth and admin.
Triage (AI-Manager)
Priority: P1 | Size: Medium | Agent: @qa-engineer
Execution order: Wave 2 -- Best done after #147, #150, #152 land so tests cover final implementation.
Dependencies: Soft dependency on #147, #150, #152.
Scope: Add pytest tests for registration, login, protected routes, token refresh, expired/invalid tokens, and admin endpoints.
Closing: this issue is already implemented on main.
tests/test_auth.pycovers registration (success, duplicate email), login (success, wrong password), protected routes (valid/invalid/expired tokens), token refresh, and admin-only endpoints.tests/test_rate_limit.pycovers rate limiting on auth endpoints.tests/test_security.pycovers JWT secret startup checks and CORS configuration.