Repository navigation
test(contract): the vehicle tests make their work item through /api/v1 - #142
Merged
Merged
Conversation
The tests that used a slice work item only as a vehicle for something else now
make it the way Plane's clients do. What moved, and what each test still reads
from the slice:
- The outbox, redelivery, sweeper and cron tests make and delete the work item
through `/api/v1`, which writes the same `work_item.created` and
`work_item.deleted` events. What the queue consumer wrote is still read from
the slice's activity feed: nothing replaces it (Plane's history, X02, holds
only the rows an event names, and a deleted or an injected event names none).
- The panic test makes its row and reads it back through `/api/v1`.
- The blast-radius test hammers Plane's internal list with a session: a key's
allowance on `/api/v1` is 60 requests a minute, which 16 clients spend at
once, and every request refused after that would count as a failure the panic
did not cause.
- `a_revoked_session_is_rejected_on_the_next_request` and
`a_session_is_not_bound_to_a_workspace` use Plane's internal work-item list
and create (S47, S48) and `GET /api/users/me/`: a session is no credential on
`/api/v1`. The API-key tests, whose keys are made on the slice's route, probe
through the same internal routes, which take a key through `thrust_api::Authed`.
- `bench` and `bench_scale` measure `/api/v1`. Each request counts against a
key's allowance, so `bench` takes a fresh member every `limit - 5` requests
and `bench_scale` makes as many admin keys as its requests need and takes them
in turn: both run under the default 60 a minute. Their numbers are not
comparable to those recorded for the slice's routes.
What the move had to accept, each a difference of the Plane route and not of
the test:
- A caller who is not in the workspace is a 403 on Plane's internal route,
where the slice's was a 404.
- The slice's create limit (`RL_CREATE`, a user's creates) has no Plane
counterpart. Plane's throttle is a key's allowance, for every request, so
`create_is_rate_limited_per_user` became `v1_requests_are_rate_limited_per_key`
and the slice's limit is no longer held over HTTP. The new test holds what
every limiter promises (the first `limit` creates pass, a 429 with a
`Retry-After` comes within `2 x limit + 1`), that a refused create makes
nothing, and that the allowance is the key's: another user's key and a second
key of the same user are not limited. (`thrust-api-v1`'s own tests hold the
throttle in process; this is the only check on a running target, so the one
that reaches the `RL_V1` binding.)
- `scripts/contract.sh` tells the suite the allowance it started the target
with (`THRUST_EXPECT_V1_LIMIT`, as for the create limit); a target started
with another one fails the test, which is its control. `stage2-contract.sh`
runs the test under its new name and refuses a limit above 1000.
No test was added or removed, so `EXPECT_MAIN` (65), `EXPECT_SWEEPER` (3) and
`EXPECT_CSRFOFF` (6) do not change.
Measured (2026-11-12): `scripts/contract.sh <target> main` 65 of 65 and `csrfoff`
6 of 6, `sweeper` 3 of 3 and `panic` 1 of 1 on `native-memory`, `native-pg`,
`worker-memory` and `worker-cf`; `blast` 1 of 1 on `native-memory` and
`native-pg` (26893 and 8889 requests, none failed); `cron` 1 of 1 on both
Workers. Controls, native-memory, each fails its pass: `no-activity-dedupe`
fails `redelivered_event_is_processed_once`; `ignore-revoked` fails
`a_revoked_session_is_rejected_on_the_next_request` (and 6 more); `ignore-tenant`
fails the outbox test's tenant-B control (403 where 404 is wanted); a target started with 1000 a minute
while the suite is told 60 fails the allowance test ("none of the first 121
creates was limited"), on `native-memory` and on `worker-cf` (where it is the
`RL_V1` binding written with 1000); a limiter that counts per user and not per key fails it
at "the same user's other key"; a fixture whose `dual` is in one workspace
only fails `a_session_is_not_bound_to_a_workspace` at "dual in workspace B".
`scripts/contract.sh native-memory bench` and `scale` (3000 rows) and
`native-pg scale` run to exit 0.
Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
G-26 lists stage 4 as moved, with what each test still reads from the slice (the activity feed), what the move accepted (a 403 where the slice's was a 404, and the slice's create limit no longer held over HTTP: the test is now a key's allowance on `/api/v1`) and what is still the slice's. The contract-suite and performance pages, the defect matrix (X20) and D-18 name the renamed test, and say that the bench and scale numbers are not comparable to those recorded for the slice's routes. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The attachment routes are the slice's and nothing replaces them, so the test still puts, reads and deletes through them; the work item they are put on was only a vehicle, and is made through `/api/v1` like the other vehicle tests'. It was the last test outside the slice's own that made a work item through the slice's create. G-26 says so. Measured (2026-11-12): `scripts/contract.sh <target> main` 65 of 65 on `native-memory`, `native-pg`, `worker-memory` and `worker-cf` (the blob store is the memory one, an in-process one and R2 respectively); `cargo fmt --all --check` and `cargo clippy -p thrust-contract-tests --all-targets -- -D warnings` clean. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Picks up #143 (the clippy 1.100 fix), the only commit main gained since the last rebase, so that `lint` is green on this branch. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 15, 2026
…tests (#172) * test(contract): port the slice's OIDC checks that the compat tests lacked Step 5d of moving off /api/_slice: the slice's OIDC pair (`GET /api/_slice/auth/oidc/start` and `/callback`) has a Plane-shaped replacement since #163 (`GET /auth/oidc/` and `/auth/oidc/callback/`, D-040), so the pair and its six `oidc_` tests can go. #163's `compat_oidc_*` tests already cover most of what the six assert (login completes, the link decides by subject, a tampered, unknown, missing, refused or replayed state, the five ID-token tamperings, no verified email, no provisioning, a deactivated user by email and by link). Five assertions of the six were in no compat test, and deleting the six without them would lose real coverage, so they come first, while the slice route still exists to compare with. No test is added: they go into the two existing compat tests, so the main pass stays 73 of 73. Ported: - The OIDC session's cookies carry the attributes of a password sign-in's (Secure, HttpOnly, SameSite=Lax, Path=/, no Domain, Max-Age 30 days), a 64-hex session token and a 32-hex CSRF value. Before this, the hermetic test held Secure, HttpOnly, Lax, Path and Domain, and nothing held Max-Age for the OIDC callback. - A different subject with another account's verified email is a different login and goes to that account (the control for "the subject decides"). - The email is matched like a password sign-in's: case and padding do not matter. - A subject that is already linked does not get around the verified-email rule (a different code path from the three unlinked cases). - The mock identity provider refuses an exchange whose PKCE verifier is not the challenge's (the control that shows the target's own verifier is what makes the logins work). Controls, each a temporary mutation of one file that was reverted (the tree was clean again after each, checked), each run through the native-memory main pass. The compat test named failed at the ported assertion, read from its panic message: - The callback's cookies live half as long: `compat_oidc_login_completes...` fails at "30 days" (Max-Age 1296000). - The provider's email is not normalized: `compat_oidc_login_completes...` fails because the padded-email login is refused (the panic is in the helper's "a session cookie"; that login is the only one whose email is not already normalized). - The link is made on the issuer and not the subject: `compat_oidc_login_completes...` fails at "a different subject is a different login" (and `compat_oidc_every_refusal...` fails too, earlier, because the memory adapter's links are shared by every test of the run). - The verified-email rule is applied only to an identity not yet linked: `compat_oidc_every_refusal...` fails at "a linked subject with an unverified email" (the slice's own test failed too). - The mock accepts any PKCE verifier: `compat_oidc_login_completes...` fails because the exchange answered 200 and not 400. Checked: native-memory main 73 of 73 with the ports in. Not run here: the other three targets (CI runs them). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * refactor(api): delete the slice's OIDC routes and their six contract tests Step 5d of moving off /api/_slice. #163 put Plane's routes (`GET /auth/oidc/` and `/auth/oidc/callback/`, D-040) over the same core `oidc_start` and `oidc_callback`, with `compat_oidc_*` contract tests, so the slice's pair has a Plane-shaped replacement and the owner's standing decision of 2026-11-11 applies: it goes. The previous commit ported what the six `oidc_` tests held that the compat tests did not. Deleted: - `GET /api/_slice/auth/oidc/start` and `/callback`, their handlers and the callback's query struct (thrust-api), and the two unused imports they leave; the two entries of `slice_auth_routes()` (so `the_slice_routes_are_gone_from_the_reserved_v1_prefix` walks 5 routes there, no longer 7) and its `no_redirect` comment. - The six `oidc_` tests of `tests/auth/mod.rs` and their helpers (`begin`, `finish`, `assert_logged_in`, `assert_refused`, `unique_sub`, the mock-IdP import). `EXPECT_MAIN` is 67. Changed: - `scripts/contract.sh` registers the mock identity provider's redirect URI as `<origin>/auth/oidc/callback/`, the app's callback (D-040 says a deployment must register that one), where it was the slice's callback. The compat tests send the browser to the URL the mock hands back, and assert that it is the app's callback, so the registration is no longer a path the target happens not to look at. No deployment has a provider (G-35), so no registration moves. - A hole found by running the mutants: G-35 records that `mutant_oidc_state_reusable` was killed at contract level only by the slice's replay test. The compat route tells a used state and a used code alike (5301) and the mock refuses a reused code too, so with the six gone the `oidc-state-reusable` row of `scripts/mutants.sh` survived: the main pass was 67 of 67 with the mutant built in. The compat refusal test now replays a used state with a second, fresh code for the same login (the mock's `authorize` can be called twice on one Location); only the used state can refuse that code, and the mutant is killed there. - Comments and docs that named the slice's pair: flows/app.md (the route rows, the OIDC paragraph, which now describes the compat routes and their redirects with `error_code`, and the error table's OIDC cases and 502 row), contract-suite.md, defect-matrix.md (X24 names the compat tests and the three mutants), status.md (G-12, G-26 with the step and its controls, G-35's note on the state mutant), the compat OIDC module's header and the stage2 script's comment. Not changed: `scripts/stage2-contract.sh` still expects 59 for its `main` set. It skips every `oidc_` test, so the set does not change here; the list of that set is 61 on main today, so the 59 was already out of date before this commit (set at #128). It is a guard of a manual run against a deployed Worker, and what it should now say needs a run there. Checked on this tree: - native-memory main 67 of 67, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4; worker-memory main 67 of 67; worker-cf main 67 of 67 (both again after the replay assertion went in). - clippy `--workspace --all-targets -D warnings` and `cargo fmt --all --check` clean; every script of CI's `deps` job and its self-tests pass; `sh -n` of `contract.sh` and `stage2-contract.sh` under dash in Ubuntu 24.04, with a deliberately broken script that fails the check. Controls (temporary, restored and checked): - The OIDC pair back in `slice_auth_routes()`: `the_slice_routes_are_gone_from_the_reserved_v1_prefix` fails ("GET /api/_slice/auth/oidc/start: not mounted (404)"), so the routes are gone and the list would notice. - The three OIDC rows of `scripts/mutants.sh`, on native-memory main with the slice tests gone: `mutant_unverified_email` and `mutant_oidc_failure_redirect_no_code` fail `compat_oidc_every_refusal...` (exit 101); `mutant_oidc_state_reusable` passed 67 of 67 before the replay assertion, and fails `compat_oidc_every_refusal...` at "a fresh code for a state that is used" after it. Not run here: native-pg (CI runs it) and a deploy. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * fix(scripts): stage2's main pass counts 61 tests, not 59 `scripts/stage2-contract.sh main` ends with a guard: when `cargo test` exits 0 and the passed count is not `EXPECT`, it exits 5 ("exit 0 but passed count != expected"), so that a filter that selects nothing cannot report green. `EXPECT` for `main` was 59, set at #128. The set its filters select is 61: #151 added two tests (`compat_change_password_is_for_a_session_and_not_for_an_api_key` and `compat_change_password_refuses_in_planes_order_changes_nothing_then_swaps_it_and_ends_every_session`), and nothing in CI runs this script (it needs a deployed Worker, by hand), so nothing noticed. A correct run against a Worker would have failed at the guard. Found while finishing step 5d, which does not change this set (the script skips every `oidc_` test, before and after). Measured, not assumed: for each pass of the script, the number of tests its own filters select (`cargo test -p thrust-contract-tests --test <binary> -- --list --format terse`, the `: test` lines), next to the `EXPECT` it holds. Before: `main` 61 listed, 59 expected, flagged as differing. After: all thirteen passes agree (main 61, csrfoff 6, worker 1, bindings 3, cron 1, crontrigger 1, sweeper 3, panic 1, blast 1, email 1, engine 4, budget 1, ratelimit 1). Only `main` was wrong. The two extra tests were found by listing the test names of the suite at #128 and of today's `main` set: the change-password pair is new; `v1_requests_are_rate_limited_per_key` is also not in the old list but is the create-limit test renamed at stage 4 (#142), so it is not an addition. Changed: - `EXPECT` for `main`, 59 to 61, and the header's "59 tests", with a comment in the script that says how to derive the number again and what went wrong this time. - `docs/src/testing/techniques/contract-suite.md`: the two places that quote the count (59, and a 31 from the spike's time) say 61 and name what the pass skips. - G-26 in `docs/src/testing/status.md` records it. Checked: `sh -n` of the script under dash in Ubuntu 24.04, with a deliberately broken script that fails the check; the thirteen counts above. Not run: the script itself against a Worker (it needs a deployed one). The 61 ties out against the runs of this PR: `main` is 67 tests, the script skips three `oidc_` and three `operator_` tests, and all 67 passed on `worker-cf` and on `worker-memory`. A run against a deployed Worker is what shows that all 61 pass there, and what shows whether either change-password test needs something a deployed Worker lacks. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.
What
Stage 4 of moving the contract suite off the slice (G-26 in
docs/src/testing/status.mdis the ledger; stages 1, 2a, 2b and 3 were #122, #125, #128 and #136). The tests that used a slice work item only as a vehicle for something else make it through/api/v1now, the way Plane's clients do.Part of #58 (not closing it).
What moved
/api/v1, which writes the samework_item.createdandwork_item.deletedevents. What the queue consumer wrote is still read from the slice's activity feed: nothing replaces it (Plane's history, X02, holds only the rows an event names, and a deleted or an injected event names none)./api/v1./api/v1; the attachment is still put, read and deleted through the slice's route, which nothing replaces./api/v1is 60 requests a minute, which 16 clients spend at once, and every request refused after that would count as a failure the panic did not cause.a_revoked_session_is_rejected_on_the_next_request,a_session_is_not_bound_to_a_workspace: Plane's internal work-item list and create (S47, S48) andGET /api/users/me/. A session is no credential on/api/v1, which reads a key and nothing else.thrust_api::Authed. Not on your list; they used a slice work item only as a probe, so they went with it.benchandbench_scalemeasure/api/v1. Each request counts against a key's allowance, sobenchtakes a fresh member everylimit - 5requests andbench_scalemakes as many admin keys as its requests need and takes them in turn: both run under the default 60 a minute.What the move had to accept
Each is a difference of the Plane route, not of the test:
RL_CREATE, a user's creates) is no longer held over HTTP. Plane has no such limit; its throttle is a key's allowance of 60 a minute for every request. Socreate_is_rate_limited_per_userbecamev1_requests_are_rate_limited_per_key: the firstlimitcreates pass, a 429 with aRetry-Aftercomes within2 x limit + 1, a refused create makes nothing, and the allowance is the key's (another user's key and a second key of the same user are not limited).thrust-api-v1's own tests hold the throttle in process; this is the only check on a running target, so the one that reaches theRL_V1binding onworker-cf. The slice's limit goes with the slice; its exact rule isMemoryRateLimiter's.scripts/contract.shtells the suite the allowance it started the target with (THRUST_EXPECT_V1_LIMIT, as it does for the create limit), so a target started with another one fails the test: that is its control.stage2-contract.shruns the test under its new name and refuses a limit above 1000.benchandbench_scaleprint is not comparable to what was recorded for the slice's routes: a create reads the project's states and members and writes the item's attributes and a history, a list is a page of at most a hundred, a search spans the workspace.No test was added or removed, so
EXPECT_MAIN(65),EXPECT_SWEEPER(3) andEXPECT_CSRFOFF(6) do not change, and this PR does not touch those lines (the ones every PR that adds a test conflicts on).Still the slice's
Sign-out-everywhere, the session info, OIDC, the API-key routes, the activity feeds, attachments, the slice's model and access matrix (for what nothing replaces: the feeds, attachments,
with_deleted, what the consumer does with an event), the round-trip budget's entry for the slice's list, andthe_slice_routes_are_gone_from_the_reserved_v1_prefix. After this PR the only tests that call the slice's work-item routes are those whose subject is the slice: its model and access matrix, the activity-feed reads above, the retired-prefix test (it calls every slice route to show it is mounted there and not under/api/v1) and the budget's entry for the slice's list.What is left of #58's contract-suite migration (G-26): deleting the slice's routes,
SLICE_PREFIX, the retired-prefix test and the core, port and adapter code only the slice used, after movingscripts/measure-argon2.shto/auth/sign-in/; then the utoipa schema andoasdiff.Evidence (2026-11-12, local)
scripts/contract.sh <target> main: 65 of 65 onnative-memory,native-pg,worker-memoryandworker-cf;csrfoff6 of 6,sweeper3 of 3 andpanic1 of 1 on all four;blast1 of 1 onnative-memoryandnative-pg(26893 and 8889 requests around the panic, none failed);cron1 of 1 on both Workers.native-memory, each fails its pass and does:no-activity-dedupe(main):redelivered_event_is_processed_onceand the slice model;ignore-revoked(main): 7 tests, among thema_revoked_session_is_rejected_on_the_next_request;ignore-tenant(main): 7, among them the outbox test at its tenant-B control (403 where 404 is wanted);v1_requests_are_rate_limited_per_key("none of the first 121 creates was limited"), onnative-memoryand onworker-cf(theRL_V1binding written with 1000);thrust-api-v1, reverted): the same test at "the same user's other key";dualis in workspace A only (planted, reverted):a_session_is_not_bound_to_a_workspaceat "dual in workspace B". No existing mutant touches that test (ignore-tenantbreaks the slice's tenancy check, and the test goes through Plane's routes now), which is why it has this one.scripts/contract.sh native-memory benchandscale(3000 rows, 500 a project) andnative-pg scalerun to exit 0 under the default allowance, so the key rotation works.cargo fmt --all --checkandcargo clippy -p thrust-contract-tests --all-targets -- -D warnings: clean.scripts/mutants.sh(themutantsjob runs it; the three mutants above are three of its rows, run by hand the way it runs them);blast,benchandscaleon the Worker targets; the deployed-Worker passes ofstage2-contract.sh, among themstage2_cron_real_trigger_runs_the_sweeper, which was changed the way the local cron test was but only compiled; thee2epass.🤖 Generated with Claude Code