Add sinon/rewire unit tests for OCSP verification#490
Add sinon/rewire unit tests for OCSP verification#490claude[bot] wants to merge 2 commits intomainfrom
Conversation
…ncies Cover the specific scenarios requested in #119 that were missing from the existing smoke-test style coverage: - `performOCSPCheck()`: use rewire to inject a mock for `getCertStatus` from easy-ocsp (which has non-configurable exports) and assert good, revoked, unknown, AbortError/timeout, network-error, timeout forwarding, and OCSP URL passthrough paths. - `verifyOCSP()`: clear require cache per test and stub `getCertificateCacheTable` on verificationUtils so each test gets an isolated cache table mock; covers cache-hit good/revoked, cached flag (hit vs source-fetch), null-cache fail-closed/fail-open, and context passthrough. Closes #119 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Reviewed; no blockers found. |
|
@claude run |
Fixes formatting issues flagged by prettier in PR #490. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Closing + reopening to force CI retrigger — Claude's format-fix commit was authored by github-actions[bot], and GITHUB_TOKEN-pushed commits don't trigger downstream workflows (deliberate loop-prevention guard). Reopening will fire pull_request.reopened on the current HEAD. |
kriszyp
left a comment
There was a problem hiding this comment.
I thought we were trying to reduce our usage of rewire (incompatible with TypeStrip), but whatever, hard to turn down more tests 🤷 .
Yep. I need to tell claude. It saw what had been used elsewhere and went with it. I'll have it re-try after some workflow update(s). |
Summary
performOCSPCheck()tests usingrewireto mock thegetCertStatusexport fromeasy-ocsp(which has non-configurable property descriptors, sosinon.stubcan't be used directly). Covers good, revoked (with and without reason), unknown, AbortError/timeout, network-error, timeout forwarding, and OCSP URL passthrough.verifyOCSP()tests that clear the require cache per test and stubgetCertificateCacheTableonverificationUtilsso each test gets an isolated cache mock. Covers cache-hit good/revoked,cachedflag (hit vs source-fetch), null-cache fail-closed/fail-open, and context passthrough to the cacheget()call.Existing tests (smoke-test style with invalid certs) are unchanged.
Test plan
npm run test:unit:security— 325 passing (up from 310), 1 pending, 2 pre-existing failures unrelated to cert verificationCloses #119
🤖 Generated with Claude Code