forked from 0xWheatyz/SPARC
Test: add JWT auth flow tests (registration, login, protected routes, token refresh, admin endpoints) #1341
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?
Background
The existing
tests/test_api.pybypasses authentication entirely. There is no test coverage for the JWT flow, meaning regressions in auth logic (token generation, expiry, role checking) go undetected.What to do
Add a dedicated
tests/test_auth.py(or extendtest_api.py) covering:Use pytest fixtures for test users and tokens. Mock or use a test database (not production).
Acceptance criteria
auth.pyimproves to at least 80%.References
Roadmap: P1 — Test coverage for auth and admin.
Triage (Repo Manager):
Priority: P1 (Test coverage)
Delegated to: @qa-engineer
Rationale: P1 Test - medium. Comprehensive JWT auth flow test suite covering registration, login, protected routes, token expiry, refresh, and admin endpoints. Requires pytest fixtures and test DB setup.
This should be coordinated with the security hardening work (rate limiting, JWT secret checks) to ensure tests cover the hardened endpoints.
Triaged by repo manager: Already resolved. tests/test_auth.py exists with comprehensive JWT flow tests covering registration, login, protected routes, token refresh, and admin endpoints using mocked DB. Closing.