forked from 0xWheatyz/SPARC
Add JWT auth integration tests (registration, login, protected routes, admin) #643
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 authentication entirely. There are no tests exercising the JWT flow, meaning regressions in the auth system could go unnoticed.What to do
Add a new test file (e.g.
tests/test_auth.py) or extend the existing test suite to cover:Use
httpx.AsyncClientor the FastAPITestClient.Acceptance criteria
pytestwithout extra setup beyond existing fixturesClosing as already implemented.
tests/test_auth.pycontains comprehensive JWT auth integration tests covering registration (first user admin, subsequent user role, duplicates), login (valid/invalid credentials), protected routes, token refresh, and admin operations (list users, change roles).