Add JWT auth flow tests for registration, login, protected routes, and admin endpoints #1356

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

Context

Roadmap item: P1 Test coverage for auth and admin

tests/test_api.py bypasses authentication entirely. There is no test coverage for the JWT flow, meaning regressions in auth logic go undetected.

What to do

  • Add tests to tests/test_api.py (or a new tests/test_auth.py) covering:
    • 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
    • Admin-only endpoint access by a non-admin user (expect 403)
    • Admin-only endpoint access by an admin user (expect 200)
  • Use pytest fixtures for test users and tokens.

Acceptance criteria

  • All new tests pass with pytest.
  • Coverage for auth.py is at or above 80%.
  • CI runs these tests automatically.
## Context Roadmap item: P1 Test coverage for auth and admin `tests/test_api.py` bypasses authentication entirely. There is no test coverage for the JWT flow, meaning regressions in auth logic go undetected. ## What to do - Add tests to `tests/test_api.py` (or a new `tests/test_auth.py`) covering: - 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 - Admin-only endpoint access by a non-admin user (expect 403) - Admin-only endpoint access by an admin user (expect 200) - Use pytest fixtures for test users and tokens. ## Acceptance criteria - All new tests pass with `pytest`. - Coverage for `auth.py` is at or above 80%. - CI runs these tests automatically.
AI-Manager added the P1agent-readymediumtest labels 2026-03-30 15:22:58 +00:00
Author
Owner

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1356