test: pin visitor counting, questionnaire auth, and session cleanup - #117
Draft
cursor[bot] wants to merge 11 commits into
Draft
test: pin visitor counting, questionnaire auth, and session cleanup#117cursor[bot] wants to merge 11 commits into
cursor[bot] wants to merge 11 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>
…dentity These contracts lived under tests/ (which CI cannot type-check) or skipped whenever typst/qpdf were absent. Colocate them next to the production code and run them on the check job so a hostile session id, a forged X-Forwarded-For, or a guessed "yes" cannot regress silently. Co-authored-by: Ralphie B. <nyagrodha@users.noreply.github.com>
…match The /gate page still posts answers through /api/gate, which had no tests. These pin fail-closed encryption, the public metrics allowlist, magic-link token mismatch before the database, wearable token format, DATABASE_URL parsing, and rust-server connection-string redaction. Co-authored-by: Ralphie B. <nyagrodha@users.noreply.github.com>
Cover production paths that shipped without tests and that the open coverage PRs do not already pin: profile owner-from-cookie and reserved handles, rust /api/store input bounds plus fail-closed recipient parse, /api/responses not echoing the email, public /api/metrics publishing counts only, and /gate Secure cookies plus the missing-token bounce. Co-authored-by: Ralphie B. <nyagrodha@users.noreply.github.com>
Cover production gaps that the open coverage PRs do not: the in-memory audience count (bots, cap, unlinkability), the /questionnaire JWT bounce before any session lookup, the 30-day cleanup keyed off last visit, and the delivery mailer's argv contract. CI now also runs the existing keystore, bundle, and co-op QR tests that were passing locally and running nowhere. 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>
Union CI path lists so /api/gate fail-closed, the beacon allowlist, and verify-mismatch suites sit next to the stacked delivery/consent tests. Keep this branch's rust-server cargo test job. Co-authored-by: rbauer <rbauer@colorado.edu>
Keep both rust-server test suites: store bounds / recipient fail-closed from this branch, and DATABASE_URL redaction from #115. Union the CI Deno path list so profile, metrics, and gate page tests sit next to the stacked coverage. Co-authored-by: rbauer <rbauer@colorado.edu>
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.
Risky behavior now covered
recordVisit): one person in a window is one visitor; bots do not inflate the headline number; empty user agents still count as people; unknown hosts cannot mint asitelabel; the tracked set stops at the cap and records that the figure is a floor; the window key is non-extractable; a new window mints a new key so the previous count cannot be joined./questionnairewithout a JWT cookie, or with a forged one, bounce to/before any session lookup. The token is not placed onLocation.updated_at(last visit), notcreated_at; the session INSERT never stores the opaque token or a plaintext email; completed sessions cannot be resumed./proc/<pid>/cmdline.CI now also runs the existing hermetic keystore, bundle-validation, and co-op QR tests that were passing locally and running nowhere.
Test files added/updated
lib/audience_test.ts(updated) — in-memory count, bots, cap, unlinkabilitylib/audience.ts— tiny test hooks (_windowSnapshotForTest,_setMaxTrackedForTest); production path unchanged aside from readingtrackedCap(defaults toMAX_TRACKED)routes/questionnaire_auth_test.ts(added)lib/questionnaire-session_test.ts(added)romania/tests/mailer_argv_test.ts(added).github/workflows/ci.yml— runs the new files plusromania/tests/{keystore,service}_test.tsandroutes/WillyStCo{op,-op}_test.tsWhy these tests materially reduce regression risk
These are the production paths every visitor and every questionnaire hit, and they were untested at the counting/auth/cleanup layer. A bot counted as a person, a cap that stopped being enforced, a forged JWT that advanced a session, a cleanup keyed off minting time, or an address on argv would all ship as silent security or privacy failures. None of this overlaps the open coverage PRs (#112 JWT/callback, #114 consent/session-keys/contact, #115 gate API/beacon/verify/wearable, #116 profile/store-bounds/metrics/gate cookies).
Hermetic: no Postgres, no SMTP, no qpdf. 122 Deno tests passed locally, including the full CI set.
No production behavior changes besides the audience cap reading an overridable binding that tests reset to
MAX_TRACKED.