forked from 0xWheatyz/SPARC
Add JWT authentication tests: registration, login, protected routes, token refresh, admin endpoints #855
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 API tests in
tests/test_api.pybypass authentication entirely. There is no test coverage for the JWT flow, meaning regressions in auth logic go undetected.Work to do
Create a new test file
tests/test_auth.py(or extend the existing test file) with tests covering:/auth/registerwith valid data returns 201 and a user object./auth/loginwith correct credentials returns a JWT access token.Acceptance criteria
pytestexits 0 with all tests passing.auth.pyincreases measurably.Resolved in codebase. tests/test_auth.py contains comprehensive tests: TestRegister (3 tests), TestLogin (2 tests), TestGetMe (4 tests including expired/refresh token rejection), TestRefreshToken (3 tests), TestAdminUsers (5 tests). Closing as implemented.