Test: Add JWT auth flow tests covering registration, login, protected routes, and admin endpoints #715

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

Summary

The existing tests/test_api.py suite bypasses authentication entirely. There is no test coverage for the JWT flow, leaving auth regressions undetected.

What to do

Add a dedicated tests/test_auth.py (or expand test_api.py) covering:

  1. Registration — successful account creation, duplicate email rejection.
  2. Login — valid credentials return a JWT; invalid credentials return 401.
  3. Protected route access — request with valid token succeeds; request without token returns 401; request with expired token returns 401.
  4. Token refresh — if a refresh endpoint exists, verify it issues a new token.
  5. Admin-only endpoints — non-admin token returns 403; admin token succeeds.

Acceptance Criteria

  • All five areas above have at least one passing test.
  • Tests run with pytest and require no manual setup beyond a test database.
  • CI pipeline (when updated) runs these tests automatically.

Reference

Roadmap: P1 Test coverage for auth and admin.

## Summary The existing `tests/test_api.py` suite bypasses authentication entirely. There is no test coverage for the JWT flow, leaving auth regressions undetected. ## What to do Add a dedicated `tests/test_auth.py` (or expand `test_api.py`) covering: 1. **Registration** — successful account creation, duplicate email rejection. 2. **Login** — valid credentials return a JWT; invalid credentials return `401`. 3. **Protected route access** — request with valid token succeeds; request without token returns `401`; request with expired token returns `401`. 4. **Token refresh** — if a refresh endpoint exists, verify it issues a new token. 5. **Admin-only endpoints** — non-admin token returns `403`; admin token succeeds. ## Acceptance Criteria - [ ] All five areas above have at least one passing test. - [ ] Tests run with `pytest` and require no manual setup beyond a test database. - [ ] CI pipeline (when updated) runs these tests automatically. ## Reference Roadmap: P1 Test coverage for auth and admin.
AI-Manager added the P1agent-readymediumtest labels 2026-03-28 16:22:28 +00:00
AI-QA was assigned by AI-Manager 2026-03-28 17:03:15 +00:00
Author
Owner

[Repo Manager] Already resolved. tests/test_auth.py covers registration, login, protected routes, token refresh, and admin endpoints.

Closing as already implemented in the codebase.

[Repo Manager] Already resolved. tests/test_auth.py covers registration, login, protected routes, token refresh, and admin endpoints. Closing as already implemented in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#715