Skip to content

test(auth,gateway): cover pending-less pair and window slide guard#50

Merged
adriannoes merged 3 commits into
developmentfrom
cursor/test-coverage-automation-102e
Jul 16, 2026
Merged

test(auth,gateway): cover pending-less pair and window slide guard#50
adriannoes merged 3 commits into
developmentfrom
cursor/test-coverage-automation-102e

Conversation

@cursor

@cursor cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • Cover auth_pair when no pending pairing code was issued (fail closed).
  • Cover ASAP rate-limit over-limit hits near the window edge so window_start cannot be slid forward.

Risky behavior now covered

  • Pairing without bootstrap must not mint a bearer token.
  • Clients cannot keep an ASAP rate window alive forever by retrying while limited.

Test files added/updated

  • tests/test_auth.ctest_auth_pair_rejects_without_pending_code
  • tests/test_rate_limit.ctest_limited_calls_do_not_extend_window

Why this reduces regression risk

These are auth fail-closed and rate-limit availability edge paths. A silent refactor that issues tokens without a pending code, or that refreshes window_start on every limited hit, would otherwise ship without CI signal.

Validation

make GATEWAY=0 test_auth test_rate_limit && ./build/test_auth && ./build/test_rate_limit

Both binaries reported all tests passed.

Notes

Does not overlap open drafts #48/#49 or branch cursor/test-coverage-automation-c4f4 (table-full / single-use pairing).

Open in Web View Automation 

@adriannoes
adriannoes changed the base branch from main to development July 16, 2026 20:01
Pin auth_pair's 16-token store cap (oldest eviction), reject non-6-digit
codes, and reject length-mismatched bearer tokens to reduce auth DoS and
bypass regression risk.
@adriannoes
adriannoes force-pushed the cursor/test-coverage-automation-102e branch from 2772e39 to a9c47a7 Compare July 16, 2026 20:02
@adriannoes
adriannoes marked this pull request as ready for review July 16, 2026 20:02
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown
Author

PR Summary

Low Risk
Test-only changes with no modifications to auth or rate-limit implementation code.

Overview
Adds unit tests only—no production changes—to lock in gateway auth and ASAP rate-limit edge behavior that is easy to break in refactors.

tests/test_auth.c gains JSON helpers and several new cases: pairing fails closed when no pending code was issued; malformed pairing codes are rejected without minting tokens; at the 16-token cap, pairing evicts the oldest token while keeping the list size fixed; token validation rejects length mismatches; and when the 32-slot lockout table is full, slot 0 reuse drops the first IP’s lockout while other IPs stay locked.

tests/test_rate_limit.c adds test_limited_calls_do_not_extend_window, asserting that over-limit hits near the window edge do not slide window_start, so clients cannot keep a rate window alive indefinitely by retrying while limited.

Reviewed by Cursor Bugbot for commit 840d4ef. Bugbot is set up for automated code reviews on this repo. Configure here.

Pin lockout_find_or_create's full-table policy: the 33rd IP reuses
slot 0, dropping the first IP's lockout while later slots stay locked.
Reject auth_pair when no pairing code was issued, and prove over-limit
ASAP hits near the window edge do not extend window_start so clients
still regain a full RPM allowance after the original window expires.
@adriannoes
adriannoes force-pushed the cursor/test-coverage-automation-102e branch from a9c47a7 to 840d4ef Compare July 16, 2026 20:03
@adriannoes
adriannoes merged commit bc5596f into development Jul 16, 2026
2 checks passed
@adriannoes
adriannoes deleted the cursor/test-coverage-automation-102e branch July 16, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant