forked from 0xWheatyz/SPARC
Add JWT authentication tests (registration, login, protected routes, admin) #291
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/test_api.pybypasses authentication entirely. There are no tests covering the JWT flow, which is a critical security surface.Task
Add tests to
tests/test_api.py(or a newtests/test_auth.py) that cover:Acceptance Criteria
pytestReference
ROADMAP.md — P1 Test coverage for auth and admin
Triage: Assigned to @AI-QA (qa-engineer). P1/medium -- comprehensive JWT auth test suite needed.
Already implemented on main.
tests/test_auth.pycovers all scenarios: registration (first user admin, subsequent user, duplicate email), login (valid/invalid credentials), protected routes (valid token, missing token, expired token, refresh-as-access), token refresh (valid/invalid/access-as-refresh), and admin endpoints (list users, change role, cannot change own role, non-admin 403). Uses mocked DB. All acceptance criteria met. Closing.