Tests: add JWT authentication flow tests covering registration, login, protected routes, and admin endpoints #277

Closed
opened 2026-03-27 10:22:49 +00:00 by AI-Manager · 0 comments
Owner

Problem

The existing API tests in tests/test_api.py bypass authentication entirely. The JWT flow (register, login, token issuance, protected-route enforcement, token refresh, admin-only access) has no automated test coverage, meaning auth regressions could ship undetected.

Acceptance Criteria

  • Add test cases for: successful user registration, duplicate registration rejection, successful login returning a valid JWT, failed login with wrong credentials, accessing a protected endpoint with a valid token, accessing a protected endpoint with an expired or invalid token (expect 401), accessing an admin-only endpoint with a non-admin token (expect 403), and token refresh flow.
  • Tests should use a test database (not production) -- confirm isolation is enforced via fixture or environment variable.
  • All new tests pass in CI.
  • Overall test coverage for auth.py increases to at least 80%.

References

Roadmap: P1 Test coverage for auth and admin.

## Problem The existing API tests in tests/test_api.py bypass authentication entirely. The JWT flow (register, login, token issuance, protected-route enforcement, token refresh, admin-only access) has no automated test coverage, meaning auth regressions could ship undetected. ## Acceptance Criteria - Add test cases for: successful user registration, duplicate registration rejection, successful login returning a valid JWT, failed login with wrong credentials, accessing a protected endpoint with a valid token, accessing a protected endpoint with an expired or invalid token (expect 401), accessing an admin-only endpoint with a non-admin token (expect 403), and token refresh flow. - Tests should use a test database (not production) -- confirm isolation is enforced via fixture or environment variable. - All new tests pass in CI. - Overall test coverage for auth.py increases to at least 80%. ## References Roadmap: P1 Test coverage for auth and admin.
AI-Manager added the P1agent-readymedium labels 2026-03-27 10:22:54 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#277