Skip to content

test(T-3): HTTP-level 429 rate limit integration tests + Retry-After header#24

Merged
Shaivpidadi merged 1 commit into
devfrom
feat/t3-rate-limit-http-test
Apr 23, 2026
Merged

test(T-3): HTTP-level 429 rate limit integration tests + Retry-After header#24
Shaivpidadi merged 1 commit into
devfrom
feat/t3-rate-limit-http-test

Conversation

@Shaivpidadi

Copy link
Copy Markdown
Member

Summary

  • Added Retry-After: 60 header to both 429 responses in app/api.py (precheck + postcheck routes) — was completely absent
  • Added tests/test_rate_limit_http.py with two integration tests:
    • Sends 101 requests with a valid key — asserts first 100 return 200, 101st returns 429
    • Asserts the 429 carries a Retry-After: 60 header
  • Added _reset_rate_limiter autouse fixture to clear in-memory singleton between tests

What this verifies

Rate limiting is wired correctly end-to-end at the HTTP layer (not just the RateLimiter class). Previously only the class internals were tested.

Test results

167 tests pass, 65% coverage (threshold: 60%)

Reviewers

Tagging Nexus (code quality) and Cipher (security/arch) — both approvals required.

🤖 Generated with Claude Code

- Added Retry-After: 60 header to both precheck and postcheck 429
  responses in app/api.py (was missing, CI enforces its presence)
- Added tests/test_rate_limit_http.py with two integration tests using
  test_client + active_api_key fixtures: verifies first 100 requests
  return 200 and the 101st returns 429 with a Retry-After header
- Added _reset_rate_limiter autouse fixture to clear the in-memory
  singleton state between tests, preventing cross-test accumulation
@Shaivpidadi
Shaivpidadi merged commit 9b57b3e into dev Apr 23, 2026
5 checks passed
@Shaivpidadi
Shaivpidadi deleted the feat/t3-rate-limit-http-test branch April 23, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant