test: lock expense list, election tallies, and document vault tenancy - #57
Draft
cursor[bot] wants to merge 1 commit into
Draft
test: lock expense list, election tallies, and document vault tenancy#57cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Route handlers for expense list/create/submit, election nominations/tallies, and document list/upload/delete were only covered by the static auth-marker scan after #44. These tests lock cross-union isolation, session tenant stamps, and extra-key rejection on those mutating paths. Co-authored-by: Ryan Morris <ryan@ryanmorris.ca>
This was referenced Sep 4, 2026
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.
Summary
After #44, expense approve/deny, election promote, ledger CRUD, and document download had route tests — but list/create/submit, nominations/tallies, and vault upload/delete still only had the static
require*Sessionmarker scan. This run locks those mutating Hub paths so a tenancy or Zod regression cannot ship unnoticed.Risky behavior now covered
mine=1pins to the session user; unknownstatusis ignored; create rejects forged tenant keys and stamps session union/local/submitter as a draft; create 400 without a local; submit 404s another union (includingplatform_admin) without changing status; another steward cannot submit someone else's draft.tallied.Test files added/updated
src/lib/expenses/api-routes.test.tssrc/lib/elections/api-routes.test.tssrc/lib/documents/api-routes.test.tssrc/lib/validation/elections.test.tsWhy this reduces regression risk
These are money, officer-election, and confidential-file routes. A missed
unionIdfilter or a spread of a raw body onto create would leak or write across tenants. The new tests exercise the real route handlers (not just access helpers) so session gating, Zod.strict(), and adapter writes stay aligned.No production behavior changed.
Checklist
.env, keys, or real member/PII datamessages/en.jsonandmessages/fr.json(if applicable)unionIdscoping; no cross-union access)npm run lintandnpm run test:unitpassnpm run test:smoke)Test plan
npx vitest run src/lib/expenses/api-routes.test.ts src/lib/elections/api-routes.test.ts src/lib/documents/api-routes.test.ts src/lib/validation/elections.test.ts(37 passed)npx eslinton the four touched test files (clean)