Repository navigation
refactor(api): delete the slice's OIDC routes and their six contract tests - #172
Merged
Merged
Conversation
…cked 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]>
…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]>
`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]>
…-oidc One conflict, `EXPECT_MAIN` in scripts/contract.sh: this branch set it to 67 (73 less the six deleted `oidc_` tests) and #169 set it to 76 (73 plus its three password-reset tests). Both edits are independent, so it is 70. Checked against the list and not by sum: `cargo test ... --list` with the main pass's own `--skip` flags selects 70 on the merged tree, and native-memory main passes 70 of 70. Follow-on edits, because #169's three tests are in stage2's set too (they use the `/internal/issue-password-reset` test route, as the other tests of `main` use `/internal/seed`, and they are not `oidc_` or `operator_` tests): `scripts/stage2-contract.sh`'s `main` expects 64, not 61, and contract-suite.md and G-26 say so. The comparison of all 13 passes' listed counts against the script's EXPECT agrees. That count rotted twice in one day (59 → 61 at #151, 61 → 64 at #169) because nothing in CI runs the script. Checked on the merged tree: native-memory main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6; 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. Not rerun after the merge: worker-memory, worker-cf and native-pg (CI runs them). Refs: #58 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.
Part of #58; this PR does not close it.
Step 5d of moving off
/api/_slice: the slice's OIDC pair (GET /api/_slice/auth/oidc/startand/callback) goes. #163 put Plane's routes (GET /auth/oidc/and/auth/oidc/callback/, D-040) over the same coreoidc_startandoidc_callback, withcompat_oidc_*contract tests, so the pair has a Plane-shaped replacement and the owner's standing decision of 2026-11-11 applies (routes with a replacement are deleted, routes with none stay).What is in it
f591c62test(contract): port the slice's OIDC checks that the compat tests lacked. Done first, while the slice route still existed, so each assertion is shown to hold on both. Ported into the two existing compat tests (no test added): the session's cookie attributes including Max-Age; a different subject with another account's verified email going to that account; the email matched with case and padding ignored, as a password sign-in's is; a linked subject still needing a verified email (5015); the mock identity provider's PKCE control. Each has a must-fail control (halved cookie TTL, unnormalised email, a link made on the issuer, the verified-email rule skipped for linked subjects, a mock that accepts any verifier): the compat test fails at the ported assertion.7c2096erefactor(api): delete the slice's OIDC routes and their six contract tests. The two handlers and the callback's query struct (thrust-api), the sixoidc_tests oftests/authand their helpers, the pair's two entries ofslice_auth_routes()(sothe_slice_routes_are_gone_from_the_reserved_v1_prefixwalks 5 routes there, not 7; with the pair put back it fails at "not mounted (404)"), and the docs that named them.EXPECT_MAINis 67 on this commit (73 less six).57410dcfix(scripts): stage2'smainpass counts 61 tests, not 59. See below.1ff90c4Merge oforigin/main(docs(contrail): record the owner's confirmation of D-023, D-025 to D-029, D-035 and D-036 #168, feat(auth): the password reset by email, first half: the port, the token store and the routes, dark until a mail service is wired #169, docs(contrail): measure what the zxcvbn crate would cost the Worker #170). One conflict,EXPECT_MAIN(67 here, 76 on main, 70 merged; checked against the test list, not by sum). feat(auth): the password reset by email, first half: the port, the token store and the routes, dark until a mail service is wired #169's three password-reset tests are also in stage2's set, which makes its count 64.A hole this found
Deleting the six left a mutant alive. G-35 records that
mutant_oidc_state_reusablewas 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 theoidc-state-reusablerow ofscripts/mutants.shsurvived (main pass 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'sauthorizecan be called twice on one Location), which only the used state can refuse; the mutant is killed there ("a fresh code for a state that is used"). The other two OIDC rows (unverified-email,oidc-failure-redirect-no-code) are killed by the compat refusal test alone.Behaviour change to know about
scripts/contract.shregisters 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 it is the app's callback. No deployment has a provider (G-35), so no registration moves.stage2-contract.sh was stale (found while checking what 5d changes)
scripts/stage2-contract.shexpected 59 formain, and the list of that set had been 61 since #151's two change-password tests. Nothing in CI runs the script, so nothing noticed, and a correct run against a deployed Worker would have exited 5 at its count guard. It is 61 in the third commit and 64 after the merge (#169's three reset tests, which use the/internal/issue-password-resettest route that the other tests ofmainalready need). I listed the tests each of its 13 passes selects, with the script's own filters, and compared with itsEXPECT: all 13 agree. Not run against a deployed Worker, which is what shows that all 64 pass there. It has now been wrong twice in one day, so a guard that compares the two in CI would be the fix; not built here.Checked
On the merged tree (
1ff90c4):--workspace --all-targets -D warningsandcargo fmt --all --checkclean.depsjob and its self-tests pass;sh -nofcontract.shandstage2-contract.shunder dash (Ubuntu 24.04), with a deliberately broken script that fails the check.Before the merge (on
7c2096e): native-memory main 67 of 67 and engine 4 of 4; worker-memory and worker-cf main 67 of 67.Not run here: native-pg, worker-memory and worker-cf on the merged tree (CI runs them), and any deploy.
Still on the slice
Sign-out-everywhere, the session info, API-key create, list and revoke, the two activity feeds and the three attachment routes: 10 route entries in all. No Plane route replaces them, so under the 2026-11-11 decision they stay until a counterpart exists (#44 and #46 are where those come from).
SLICE_PREFIXand its test go last.🤖 Generated with Claude Code