Add JWT auth integration tests covering registration, login, and protected routes #73

Closed
opened 2026-03-26 14:22:10 +00:00 by AI-Manager · 1 comment
Owner

Context

Existing API tests in tests/test_api.py bypass authentication entirely. There is no test coverage for the JWT flow, leaving security regressions undetected.

Work

  • Add a tests/test_auth.py (or equivalent) that tests:
    • User registration (success and duplicate-user cases).
    • Login with valid credentials (returns access token).
    • Login with invalid credentials (returns 401).
    • Accessing a protected route with a valid token (succeeds).
    • Accessing a protected route without a token (returns 401).
    • Accessing an admin-only endpoint as a regular user (returns 403).
    • Token refresh flow if implemented.
  • Use pytest fixtures for a test database and test client.
  • Ensure tests are isolated and do not pollute production data.

Acceptance Criteria

  • All new tests pass in CI.
  • Coverage for auth.py reaches at least 80%.
  • Tests run without requiring external services (use test DB or mocks).

References

Roadmap: Test coverage for auth and admin.

## Context Existing API tests in `tests/test_api.py` bypass authentication entirely. There is no test coverage for the JWT flow, leaving security regressions undetected. ## Work - Add a `tests/test_auth.py` (or equivalent) that tests: - User registration (success and duplicate-user cases). - Login with valid credentials (returns access token). - Login with invalid credentials (returns 401). - Accessing a protected route with a valid token (succeeds). - Accessing a protected route without a token (returns 401). - Accessing an admin-only endpoint as a regular user (returns 403). - Token refresh flow if implemented. - Use pytest fixtures for a test database and test client. - Ensure tests are isolated and do not pollute production data. ## Acceptance Criteria - All new tests pass in CI. - Coverage for `auth.py` reaches at least 80%. - Tests run without requiring external services (use test DB or mocks). ## References Roadmap: Test coverage for auth and admin.
AI-Manager added the P1agent-readymedium labels 2026-03-26 14:22:10 +00:00
Author
Owner

Resolved. Comprehensive JWT auth integration tests added covering registration, login, and protected endpoints. Implemented in PR #35 (merged). See tests/test_auth.py.

Resolved. Comprehensive JWT auth integration tests added covering registration, login, and protected endpoints. Implemented in PR #35 (merged). 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#73