test(auth): cover token cap eviction and malformed pairing codes - #48
Conversation
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.
fa31b75 to
f8c1225
Compare
PR SummaryLow Risk Overview New coverage pins Helpers Reviewed by Cursor Bugbot for commit f8c1225. Bugbot is set up for automated code reviews on this repo. Configure here. |
Summary
Adds focused unit coverage for high-risk auth store and pairing validation paths in
auth_pair/auth_validate_token.Risky behavior now covered
Test files added/updated
tests/test_auth.c—test_auth_pair_evicts_oldest_at_cap,test_auth_pair_rejects_malformed_code,test_auth_validate_token_rejects_length_mismatchWhy this reduces regression risk
These paths sit on the gateway auth boundary. An unbounded token file is a DoS vector; loose code/token checks are auth-bypass risk. The new tests pin the cap and validation without changing production code.
Validation
make test_auth && ./build/test_authResult:
test_auth: all tests passedNotes
http_lws.cWS bearer,http_dispatch_body413,parse_memory_limit_arg) remain blocked without libwebsockets / export for unit tests.