forked from 0xWheatyz/SPARC
Add JWT authentication tests: registration, login, protected routes, token refresh, admin endpoints #904
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?
Summary
The existing
tests/test_api.pybypasses authentication entirely. There is no test coverage for the JWT flow, leaving registration, login, protected-route access, token refresh, and admin-only endpoint authorization untested.What to do
Add a new test file (e.g.
tests/test_auth.py) or extendtest_api.pywith tests covering:POST /auth/registersucceeds with valid payload; returns 400 on duplicate email.POST /auth/loginreturns a JWT on valid credentials; returns 401 on wrong password.GET /patents) returns 401 without a token and 200 with a valid token.POST /auth/refresh(or equivalent) returns a new token given a valid refresh token.Acceptance criteria
pytestruns cleanly with no auth-related warnings.Reference
ROADMAP.md — P1 Test coverage for auth and admin
Triage: RESOLVED
This issue has been fully implemented in the fork main branch.
Evidence:
tests/test_auth.pyexists with comprehensive tests for registration, login, protected route access, token refresh, and admin-only endpoints.All acceptance criteria are met. Recommending closure.