Repository navigation
ci(hubspot): add offline auth and API contract tests - #243
Open
seanspeaks wants to merge 4 commits into
Open
seanspeaks wants to merge 4 commits into
seanspeaks wants to merge 4 commits into
Conversation
added 3 commits
November 9, 2026 18:20
Emit a Binding C item 4a synthetic receipt for packages/v1-ready/hubspot. Run real getToken, refreshAccessToken, addAuthHeaders, and testAuthRequest against nock, with outbound request-shape assertions and fail-closed network-deny plus a closed token-env list. Do not wire secrets or emit an authorized label.
The receipt step in CI run 42673233531 failed after 33/33 tests because the workflow passed the jest command via HUBSPOT_RECEIPT_COMMAND, which matches the T-C4-8 HUBSPOT_ prefix. Rename to AML_RECEIPT_COMMAND, keep the CLI --command argument, and add a regression that invokes the emitter with the same env and argv the workflow uses. Also align the 4a receipt with erratum rev2: - adopt the Architect-pinned 90-day recorded freshness bound - keep synthetic fixtures off the 90-day clock - name T-C4-9 a-d (stale-but-pinned, fresh-but-unpinned, non-90 bound, API-version mismatch) - pin deny+spy hosts to api.hubapi.com and app.hubspot.com - treat set-but-empty provider env as present - install a distinct spy (nock.emitter no-match) beside disableNetConnect - exclude the unexercised hapikey / api_key path - upload the receipt artifact only when both files exist Local only; does not push.
… receipt; mark 90-day freshness adopted in docs
|
|
||
| - name: Write receipt and classification bytes | ||
| env: | ||
| AML_RECEIPT_COMMAND: npx jest --config jest.receipt.config.js --ci --watchman=false --forceExit --json --outputFile=artifacts/jest-results.json |
There was a problem hiding this comment.
The command field in the receipt is not the command that actually ran.
- The test step runs in
packages/v1-ready/hubspotwith--outputFile="${GITHUB_WORKSPACE}/artifacts/jest-results.json". AML_RECEIPT_COMMANDrecords--outputFile=artifacts/jest-results.json, which resolves topackages/v1-ready/hubspot/artifacts/...if someone replays it.- The receipt exists to record the exact command and result. Replaying the recorded command writes the JSON to a different location, and the receipt does not mention the working directory.
T-C4-8regression tests also pin this string asWORKFLOW_RECEIPT_COMMAND, so the mismatch is locked in.
Fix: make the executed command and the recorded command identical, for example by running the same string from the same directory and recording the working directory in the receipt:
env:
AML_RECEIPT_COMMAND: npx jest --config jest.receipt.config.js --ci --watchman=false --forceExit --json --outputFile=../../../artifacts/jest-results.jsonIn that case, also update WORKFLOW_RECEIPT_COMMAND to match.
Suggested change
| AML_RECEIPT_COMMAND: npx jest --config jest.receipt.config.js --ci --watchman=false --forceExit --json --outputFile=artifacts/jest-results.json | |
| AML_RECEIPT_COMMAND: npx jest --config jest.receipt.config.js --ci --watchman=false --forceExit --json --outputFile=../../../artifacts/jest-results.json | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
Rewrite HubSpot offline receipt comments, schema, and error labels into neutral open-source wording; rename hubspot-4a-policy to hubspot-auth-api-policy; align recorded Jest outputFile with the path the workflow test step actually writes. Co-authored-by: Sean Matthews <sean.matthews@lefthook.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The HubSpot module's live API tests need credentials, so they are skipped in ordinary CI. A change can therefore break token exchange, token refresh, or auth headers without the pull request checks noticing. This PR adds an offline CI job that runs the module's real auth and API code against documented HubSpot request shapes, with HTTP mocked, and publishes a JSON summary of the run.
What
.github/workflows/hubspot-auth-api-receipt.yml. It runs on changes topackages/v1-ready/hubspot/**,scripts/ci/**, the workflow file, orpackage-lock.json, and can also be started manually.packages/v1-ready/hubspot/jest.receipt.config.jsand annpm run test:receiptscript. That job runs the new synthetic auth tests plus the existingoauth,definition, andlistContactssuites. The liveapi.test.jsandauther.test.jssuites are not part of this job.api.test.jsnow runs only whenHUBSPOT_LIVE_API=1.packages/v1-ready/hubspot/tests/fixtures/, transcribed from official HubSpot docs (OAuth 2026-03,GET /integrations/v1/me,GET /crm/v3/objects/contacts). Token values aresynthetic-*placeholders, with source notes inGENERATOR.mdandprovenance.json.hubspot-auth-api-receipt, that records the command, pass/fail counts, fixture provenance, and a hash of theapi.jsfile that ran. The summary is labeledsynthetic(mocked). This PR does not add a live, credentialed run.How to test
From the repository root:
From
packages/v1-ready/hubspot:The existing
npm testscript is unchanged and still uses the package's default Jest config, including MongoMemoryServer. The new job usesjest.receipt.config.jsso it can run without that database setup.Closes #245