Skip to content

test(auth): cover lockout table full slot-0 eviction - #49

Merged
adriannoes merged 2 commits into
developmentfrom
cursor/test-coverage-automation-b173
Jul 16, 2026
Merged

test(auth): cover lockout table full slot-0 eviction#49
adriannoes merged 2 commits into
developmentfrom
cursor/test-coverage-automation-b173

Conversation

@cursor

@cursor cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Adds unit coverage for /pair brute-force lockout when the in-memory IP table is full.

Risky behavior now covered

  • Full lockout table (32 IPs): the 33rd IP reuses slot 0, so the first IP loses its lockout while later slots stay locked.

Test files added/updated

  • tests/test_auth.ctest_pair_lockout_table_full_evicts_slot_zero

Why this reduces regression risk

Lockout is the gateway's pairing brute-force control. Silent slot-0 eviction is easy to break in a refactor (LRU change, wrong free-slot scan) and would either drop protection for early attackers or fail to admit new IPs. This test pins the current policy without changing production code.

Validation

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

Result: test_auth: all tests passed

Notes

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-b173 branch from 5a24ffd to 3ec8dda 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 to auth unit tests; no modifications to pairing, token, or lockout implementation.

Overview
Expands tests/test_auth.c with helpers and integration-style cases that pin gateway auth edge behavior without changing production code.

Adds cJSON-backed helpers to seed and inspect the on-disk token JSON array, plus tests that auth_pair rejects malformed 6-digit codes (wrong length, non-digits, empty) while a valid pending code still works; that pairing at the 16-token cap evicts the oldest token and keeps array size at 16; and that auth_validate_token rejects tokens longer than the stored 32-char hex.

Adds test_pair_lockout_table_full_evicts_slot_zero, which fills all 32 lockout slots, then asserts the 33rd IP reuses slot 0 so the first IP is no longer locked out while other slots (including the new IP after max failures) remain locked—documenting current lockout_find_or_create overflow policy.

Reviewed by Cursor Bugbot for commit ce3211c. 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.
@adriannoes
adriannoes force-pushed the cursor/test-coverage-automation-b173 branch from 3ec8dda to ce3211c Compare July 16, 2026 20:03
@adriannoes
adriannoes merged commit f4ea2e8 into development Jul 16, 2026
2 checks passed
@adriannoes
adriannoes deleted the cursor/test-coverage-automation-b173 branch July 16, 2026 20:12
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