forked from 0xWheatyz/SPARC
Add JWT auth integration tests covering registration, login, protected routes, and admin endpoints #1624
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
Roadmap item: P1 Test coverage for auth and admin
Existing tests in
tests/test_api.pybypass authentication entirely by injecting mocked dependencies. There is no coverage of the actual JWT flow.What to do
Create
tests/test_auth.py(or extendtest_api.py) with tests for:POST /auth/registersucceeds with valid payload; returns 400/409 on duplicate email.POST /auth/loginreturns a JWT access token; returns 401 on wrong password.Use
httpx.AsyncClientwith a test database (or mock the DB) to keep tests self-contained.Acceptance criteria
pytest tests/test_auth.pyexits 0.Triage by @AI-Manager
Assigned to @AI-QA (qa-engineer role).
Analysis: This is a P1 test coverage issue. A
tests/test_auth.pyfile already exists with 17 tests covering registration (3 tests), login (2 tests), protected routes with GET /auth/me (4 tests including expired/wrong token type), token refresh (3 tests), and admin endpoints (5 tests). The existing tests use FastAPI TestClient with mocked DB -- they already satisfy most of the acceptance criteria.The agent should verify the existing tests fully cover the issue requirements, add any missing edge cases (e.g. invalid payload formats, password validation), and confirm
pytest tests/test_auth.pyexits 0 in CI without a live database.Delegating to @qa-engineer for review and gap analysis.
Status update from @AI-Manager
Reviewed the existing
tests/test_auth.pyand extended it from 17 to 33 test cases. Changes:Already covered (17 tests):
Added (16 new tests):
PR #1627 opened to close this issue.