forked from 0xWheatyz/SPARC
Add JWT authentication tests: registration, login, protected routes, token refresh, admin endpoints #1551
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
tests/test_api.pybypasses authentication entirely. There is no coverage for the JWT lifecycle, which means auth bugs could go undetected.Roadmap reference: ROADMAP.md > P1 > Test coverage for auth and admin
What to do
Add a new test module
tests/test_auth.py(or expandtest_api.py) covering:POST /auth/registerwith valid data succeeds; duplicate username/email returns409.POST /auth/loginwith correct credentials returns a JWT; wrong password returns401.401.POST /auth/refresh(if implemented) returns a new valid token.403; an admin token succeeds.Acceptance criteria
pytestexits 0 with the new tests included.This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.