test: pin the delivery callback, JWT, and audience opt-out - #112
Draft
cursor[bot] wants to merge 3 commits into
Draft
test: pin the delivery callback, JWT, and audience opt-out#112cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
…WT that must not carry an address The delivery confirmation route, the key-box callback, and questionnaire JWTs shipped without tests. Pin fail-closed auth, write-once pdf_delivered_at, GPC/DNT opt-out, and session tokens that verify as hashes not mailboxes. Read KEYBOX_RENDER_* and RENDER_CALLBACK_* on each call (same boot-order trap jwt.ts already documents) so the tests can set them, and so a missing .env at import cannot lock the consent path into "unavailable" forever. Co-authored-by: Ralphie B. <nyagrodha@users.noreply.github.com>
… nowhere These suites already existed or just landed; the check job never invoked them. Add --allow-write for keystore temp dirs. Leave tests/ out: it still carries the pre-existing type errors that fail before any test executes. Co-authored-by: Ralphie B. <nyagrodha@users.noreply.github.com>
Keep production's lib/gate_encrypt_test.ts on the check job alongside the delivery, auth, and audience suites this branch already added. The two edits collided on the same deno test path list after #113 landed. Co-authored-by: rbauer <rbauer@colorado.edu>
cursor Bot
pushed a commit
that referenced
this pull request
Sep 7, 2026
Union visitor-counting, questionnaire-auth, and session-cleanup tests with the stacked coverage from #112–#116. Deduplicate rust-server/target in .gitignore. This branch now merges cleanly into production and contains the earlier cursor test PRs, so they no longer conflict. Co-authored-by: rbauer <rbauer@colorado.edu>
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.
Coverage for recently merged production paths that shipped without tests, or whose tests never ran in CI.
Risky behavior now covered
POST /api/responses/delivered): unset/empty callback token fails closed (503, not "no auth"); bearer mismatch including length mismatch is 401 without throwing; traversal-shaped session ids are 400; the UPDATE is write-once (pdf_delivered_at IS NULL) so a re-send cannot restart the shred clock.notifyDelivered): a 404 is logged rather than treated as success — the failure that leftpdf_delivered_atunset for months; a network miss cannot fail a send that already happened.pushBundle): unconfigured / non-2xx / network failure all become a contentlessKeyboxUnavailableError, so a log line cannot carry the questionnaire.JWT_SECRETfail closed; the secret is read per call (the boot-order trap)./api/healthand/api/metricsare not visitors; GPC and DNT opt out; counting cannot change the response.Test files added/updated
routes/api/responses/delivered_test.ts(new)romania/tests/callback_test.ts(new)lib/romania-client_test.ts(new)lib/jwt_test.ts(new)routes/_middleware_test.ts(new)lib/emailValidator_test.ts(new)lib/questionnaire_test.ts(new)lib/crypto_test.ts(new)lib/metrics_test.ts(new).github/workflows/ci.yml— these suites, plus existinglib/audience_test.ts,lib/client-ip_test.ts,lib/qr-scans_test.ts, andromania/tests/, now run on the check job.Tiny production changes only where tests required them:
KEYBOX_RENDER_*andRENDER_CALLBACK_*are read on each call (same boot-order traplib/jwt.tsalready documents), andnotifyDeliveredis exported. No delivery, auth, or counting behavior otherwise changes.Why this reduces regression risk
The callback route existed to stamp delivery and start the shred clock; without tests, a 404 or an unset token could (and did) look like success. JWT verification is the resume capability: an expiry skip or an address in the payload would be a privacy and auth break with no other alarm. Audience middleware claims "bookkeeping cannot change what a visitor receives" and honours GPC/DNT — those were untested request-path contracts. CI was not running the lib/romania suites that already existed, so they could not have stopped a repeat.
Hermetic: no Postgres, no SMTP, no live key box.
fetchis stubbed. 184 passed locally on the expanded CI command (12 romania PDF tests ignored where typst/qpdf are absent).