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 EasypostClient and its spec from a vendor definition using the generator.
  • The check calls GET /v2/addresses with 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 403 with APIKEY.INACTIVE.
  • The generator wrote the Basic auth headers on one 122-character line:
    • Since rubocop -a split it, it broke generated_client_sync_spec.rb.
    • Therefore, we updated the generator to emit one header per line.

Notes

  • 401 stays unmapped and reads as unknown:
    • EasyPost returned it only for requests without a key.
    • EasyPost errors guide also uses UNAUTHORIZED for credentials that "do not permit access".
  • /v2/users endpoint was rejected:
    • A live test key gets 403 with MODE.UNAUTHORIZED there because it requires a production key.

MR acceptance checklist

I have evaluated this MR against the MR acceptance checklist.

Edited by Ahmed Hemdan

Merge request reports

Loading
Loading