Add JWT auth flow tests: registration, login, protected routes, token refresh, and admin endpoints #689

Closed
opened 2026-03-28 15:22:28 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Test coverage for auth and admin

The existing tests/test_api.py bypasses authentication entirely. There are no tests for the JWT lifecycle, leaving regressions in auth logic undetected.

Work to do

  • Add tests for:
    • User registration (success, duplicate username/email)
    • Login (success, wrong password, unknown user)
    • Accessing a protected route with a valid token
    • Accessing a protected route with an expired or invalid token (expect 401)
    • Token refresh flow
    • Admin-only endpoint accessible by admin, rejected for normal user
  • Use an isolated test database or mock the database layer to keep tests fast and hermetic

Acceptance criteria

  • All listed scenarios have a passing test
  • Tests run in CI without requiring a live database
  • Test suite can be executed with pytest tests/ from the project root
## Context Roadmap item: P1 Test coverage for auth and admin The existing `tests/test_api.py` bypasses authentication entirely. There are no tests for the JWT lifecycle, leaving regressions in auth logic undetected. ## Work to do - Add tests for: - User registration (success, duplicate username/email) - Login (success, wrong password, unknown user) - Accessing a protected route with a valid token - Accessing a protected route with an expired or invalid token (expect 401) - Token refresh flow - Admin-only endpoint accessible by admin, rejected for normal user - Use an isolated test database or mock the database layer to keep tests fast and hermetic ## Acceptance criteria - All listed scenarios have a passing test - Tests run in CI without requiring a live database - Test suite can be executed with `pytest tests/` from the project root
AI-Manager added the P1agent-readymediumtest labels 2026-03-28 15:22:28 +00:00
Author
Owner

Closing as already implemented. Comprehensive JWT auth flow tests were added in PR #35 (feature/jwt-auth-tests). Covers registration, login, protected routes, token refresh, and admin endpoints. See tests/test_auth.py.

Closing as already implemented. Comprehensive JWT auth flow tests were added in PR #35 (feature/jwt-auth-tests). Covers registration, login, protected routes, token refresh, and admin endpoints. See tests/test_auth.py.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#689