refactor(platform): converge itest sign-ups on signUpOrgMember - #3206
Merged
Conversation
The backend integration harness carried 22 hand-rolled copies of the "POST /api/auth/sign-up/email, parse the user id, insert a member row" sequence next to the shared helper #3198 introduced. Every copy now goes through the helper, behaviour-preserving: same role, same org, same cookie/userId flow, and no lane asserts anything differently. - `signUpUser(base, label)` is split out of `signUpOrgMember` for the nine sites that deliberately sign up WITHOUT joining the suite's org: the two cross-org attackers that go on to create their own org, the four lanes whose `POST /api/app/members` join is itself under test (member outbox hint, audit row, `joined.status`), the account-only password probe, and the two lane-local `signUp` closures (authz hardening, org lifecycle). - `signUpOrgMember` returns `memberId` (`RETURNING "id"`) so the two gate lanes that rewrite the role between passes and delete the member at the end keep addressing the row by id instead of hand-rolling one. - Left alone: the suite's primary sign-up in `checkAuthAndSse` — it IS the "sign-up issues session" check and asserts on the raw response. Net -263 lines in integration-check.ts; the README doctrine names both helpers.
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
services/platform/backend/integration-check.tscarried 22 hand-rolled copies of the sign-up sequence (POST /api/auth/sign-up/email→ parse the user id → capture the cookie →INSERT INTO "member") beside thesignUpOrgMemberhelper that #3198 introduced and converted five sites to. Structure-not-behaviour refactor: every remaining copy now goes through the shared helper. Same role, same org, same session semantics, same assertions — no lane asserts anything differently. Net −263 lines in the harness.Sites converged (22)
13 →
signUpOrgMember(a member/editor of the suite's org via the raw member row, as before): tasks-isolation read-only viewer, documents doc-reviewer (editor), document-write-guards member + editor, corpus-purge member, MCP member, conversations write-gate probe, TTS stranger, members email-lookup member, agent-secrets member, erasure member, audit read-gate probe, DSAR member.9 →
signUpUser(deliberately signed up WITHOUT joining the suite's org — the existing helper could not express these, so its sign-up half is now a sibling helper):POST /api/app/membersjoin is itself under test — member-lifecycle outbox hints, bell-wire recipient (joined.statusis asserted), board-move assignee, audit-surface member (the join lands an audit row). A raw memberINSERTthere would have removed the side effects those lanes observe, so they keep their API join and only the sign-up half converges;signUpclosures:checkAccountAuthzHardening(5 call sites; org create + members API are what it exercises) now delegates tosignUpUser;checkOrganizationLifecycle(2 call sites) drops its closure.Left alone (1)
checkAuthAndSse's primary sign-up. It is thesign-up issues sessioncheck (asserts the raw response status, cookie and user id) and creates the suite's shared user and org — not a throwaway copy.Helper changes
signUpUser(base, label)split out ofsignUpOrgMember: same email/password/name scheme, returns{ cookie, userId, email };signUpOrgMemberbuilds on it.signUpOrgMembernow also returnsmemberId(INSERT … RETURNING "id") so the two gate lanes thatUPDATE "member" SET "role" … WHERE "id"between passes andDELETEthe row at the end address it by id exactly as before, instead of hand-rollingm-conv-gate-…/m-audit-gate-…ids.Display names (
Iso Viewer→Itest iso-viewer) and email shapes (itest-<label>-<Date.now()>@example.com) change at the converged sites; no assertion references any of them (each literal occurred exactly once in the file). Three sites had deterministic emails and one anON CONFLICT ("id") DO NOTHINGon a hand-rolled member id — no-ops on the fresh per-run database.Proof —
backend:integrationon a fresh throwaway tale-db + MinIO per rundac9e71f0(origin/main when branched)webdav re-home (protocol + tree + locks + visibility on pg)— pre-existing34ccd23b2(after #3203 #3200 #3204 #3199)webdav re-home+messages: concurrent appends each take their own slot(see note)7b7ed58f5webdav re-homeFAILBase vs branch: the ordered 461-entry check-name sequence and the PASS/FAIL sequence are byte-identical (
diffof the extracted names/statuses is empty); every run reaches the final check — noRUN TRUNCATED.Post-rebase: the ordered check-name sequences of origin/main and the rebased branch are identical (461 entries). Between the two bases, #3203 removed
sandbox user-env CRUD (masked secrets, key validation)and #3204 addedshare links: snapshot carries no null blocked reason or error— 461 checks before and after. The extra FAIL on the origin/main run,messages: concurrent appends each take their own slot, is a concurrency race probe in the chat lane, outside this change's blast radius: it passed on the rebased-branch run that executed concurrently on the same machine (the two runs shared the CPU) and on both earlier runs. Its detail on the main run:messages: concurrent appends each take their own slot — appends=12, failed=2 (want 0), rows=10, distinctOrders=10 (want 12, no ties), contiguous=true.Gates
bunx tsc --noEmit(services/platform) 0 ·bunx oxlint --type-aware backend/integration-check.ts0 ·bunx oxfmt --checkclean ·bunx knip0 (one pre-existing, unrelated config hint:cron-parserinignoreDependencies).Rebase / coordination
Rebased onto origin/main after #3203 merged (it removed the sandbox user-env lane from this same file): clean, no conflicts, the lane stays removed. No migrations.