forked from 0xWheatyz/SPARC
Add JWT authentication tests covering full token lifecycle #208
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
Existing tests in
tests/test_api.pybypass authentication entirely. The JWT registration, login, protected-route, token-refresh, and admin-only code paths have zero test coverage.Roadmap reference: ROADMAP.md > P1 > Test coverage for auth and admin
What to do
Add test cases (in
tests/test_api.pyor a newtests/test_auth.py) covering:Use FastAPI
TestClientand a fixture that creates an isolated test database or mocks the DB layer.Acceptance criteria
pytestreports 0 failures and the new tests are included in CI output.This issue has already been resolved in the current codebase.
tests/test_auth.pycontains comprehensive JWT authentication tests covering registration, login, protected routes, token refresh, and admin access. The test file uses mocked database clients and the FastAPI TestClient.Closing as already implemented.