Loading
Add a validity check for EasyPost API tokens
🤖 AI wrote this code from my instructions.Unreviewed AI output often lands on reviewers and costs them time.
This MR is human verified: I read the full diff and ran the tests myself, because your time is as valuable as mine.
This merge request adds a validity check for EasyPost API tokens.
Related to #632650 (closed). Stacked on !259344 (merged), which strips the quotes the rule captures.
Gap
- GitLab detects
EasyPost API token(rule), but validity checks did not verify it.
Fix
- We generated
EasypostClientand its spec from a vendor definition using the generator. - The check calls
GET /v2/addresseswith the key as the Basic auth username, and is only enabled for GSS findings. - Every mapping decision was measured against real production and test keys:
- Live production keys return
200. - Disabled, deleted and unknown keys return
403withAPIKEY.INACTIVE.
- Live production keys return
- The generator wrote the Basic auth headers on one 122-character line:
- Since
rubocop -asplit it, it brokegenerated_client_sync_spec.rb. - Therefore, we updated the generator to emit one header per line.
- Since
Notes
401stays unmapped and reads asunknown:- EasyPost returned it only for requests without a key.
- EasyPost errors guide also uses
UNAUTHORIZEDfor credentials that "do not permit access".
/v2/usersendpoint was rejected:- A live test key gets
403withMODE.UNAUTHORIZEDthere because it requires a production key.
- A live test key gets
MR acceptance checklist
I have evaluated this MR against the MR acceptance checklist.
Edited by Ahmed Hemdan