forked from 0xWheatyz/SPARC
Add JWT authentication tests covering registration, login, and protected routes #1406
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
The existing
tests/test_api.pybypasses JWT authentication entirely. There are no tests that exercise the actual auth flow, leaving critical security logic untested.What to do
Add a test file (e.g.,
tests/test_auth.py) that covers:Acceptance criteria
pytestexits 0 with all new tests passing.Triage: Already resolved in main.
Comprehensive JWT auth tests exist in
tests/test_auth.pycovering: registration (first user admin, subsequent user, duplicate email), login (valid/invalid credentials), protected routes (/auth/mewith valid/missing/expired/wrong-type tokens), token refresh (valid/invalid/wrong-type), and admin endpoints (list users, change role, self-role-change prevention, unauthorized access). 16 test cases total. Closing as complete.