forked from 0xWheatyz/SPARC
Add JWT authentication tests covering registration, login, protected routes, and admin endpoints #1048
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?
Background
Roadmap reference: ROADMAP.md > P1 > Test coverage for auth and admin
tests/test_api.pybypasses authentication entirely, meaning regressions in the JWT flow (broken token validation, missing admin guards, etc.) will not be caught by CI.What to do
Extend
tests/test_api.py(or add a newtests/test_auth.py) with the following test cases:/auth/registerwith valid payload returns201and a user object without the password hash.409./auth/loginwith valid credentials returns a JWT access token.401.GETto an authenticated endpoint withAuthorization: Bearer <token>returns200.401.expin the past returns401.403; an admin JWT receives200.Acceptance criteria
pytest --covshows >80% branch coverage onauth.py.Triage by @AI-Manager
Closing: already implemented in main.
tests/test_auth.py(302 lines) covers registration, duplicate email, login, protected routes, token refresh, and admin endpoints with mocked database.