forked from 0xWheatyz/SPARC
Add JWT authentication tests: registration, login, protected routes, token refresh, admin endpoints #1271
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
The existing
tests/test_api.pysuite bypasses authentication entirely. There is zero test coverage for the JWT flow, meaning regressions in auth go undetected.Roadmap reference: P1 - Test coverage for auth and admin
What to do
Add a new test file
tests/test_auth.py(or extendtest_api.py) covering:Use
pytestfixtures to create test users and clean up after each test. Mock external services (database) where appropriate.Acceptance criteria
pytest tests/test_auth.pyexits 0 in CI.Triage: Already Implemented
JWT authentication tests exist on
main:tests/test_auth.pycovers registration, login, protected routes, token refresh, and admin endpoints with mocked database.tests/test_security.pycovers security-specific auth scenarios.tests/test_rate_limit.pycovers rate limiting on auth endpoints.test.yaml) runs all tests withpytest tests/ -v.Closing as completed.