Repository navigation
test(contract): move the work-item tests onto /api/v1 with API keys - #122
Merged
Merged
Conversation
The contract suite tested work items through the slice's `/api/_slice` routes with a Bearer session. Ten tests of `contract.rs` now go through `/api/v1`, with the `X-Api-Key` that the fixture plants for every user (`User.key`), and answer as Plane does: a stranger and a project that is not there are a 403, a list is newest first, the first work item in a state (here, in none) is at 65535 and the next 10000 after it, a member deletes only what they made, an external key that is taken is a 409 naming the work item, a body that is wrong is a 400 in DRF's words, and a key that is not valid is a 403 where a missing one is a 401. Each test keeps its controls (the neighbouring refusal, the nothing-was-made check). What the pin's list does not have goes with the slice's: a view of a deleted row (`scope=with_deleted`), a 400 for an unknown scope, and unique `sort_order` under concurrent creates (the pin reads the greatest one before it inserts, so two creates at once can share a place; the test asserts the numbers only). The fixture's key is labelled `FIXTURE_KEY_LABEL`, because the slice's `GET /api-keys` lists it like any other: the two key tests that assert an exact listing count only the keys they made (`made_here`). The fixture seeds no states: a work item made through `/api/v1` has none, and the compat tests seed their own default state, which a default in the shared fixture would replace. The slice's routes stay, and so do the tests that no `/api/v1` or compat route replaces yet (sessions, cookies, CSRF, OIDC, API-key management, attachments, the activity feeds, the create limit) and those that use a slice work item as their vehicle; the next stages take them. Measured (2026-11-11): the main pass, 57 of 57, on native-memory, native-pg, worker-memory and worker-cf. Controls: the `ignore-tenant` mutant fails the migrated cross-tenant test (6 failures in all), and the `duplicate-sequence-number` mutant fails the migrated create, list, soft-delete and concurrent-create tests (6 in all). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d what is left G-26 in the testing status is the ledger of the migration off `/api/_slice` (staged, the owner's choice of 2026-11-11): what has moved, what stays on the slice because no route replaces it yet, and what is not done. The contract-suite page says which surface its work-item tests use, and `by-change.md` no longer says that nothing is served under `/api/v1`. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 11, 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.
What
Stage 1 of moving the contract suite off the slice's
/api/_sliceroutes (one of the two things left of #58, with the utoipa schema diff). Ten tests ofcontract.rsnow go through/api/v1with an API key, instead of through the slice with a Bearer session, and answer as Plane does.Part of #58 (not closing it).
The shape of the whole migration is the owner's choice of 2026-11-11: staged (move what has a replacement now; the slice routes that nothing replaces stay, named, until #44 delivers them), and the work-item tests go to
/api/v1with API keys (not the compat plane, which is deleted at ADR-0013 Phase 2). G-26 indocs/src/testing/status.mdis the ledger.What changed
crates/thrust-contract-tests/src/lib.rs: every fixture user has an API key (User.key, planted through/internal/seed, labelFIXTURE_KEY_LABEL), and a small v1 client:v1_items,v1_item,v1_create,v1_create_ok,v1_list,v1_list_ok,v1_delete, andIssue(a wrapper over the JSON, for the few keys a test reads).tests/contract.rs:unauthenticated_requests_are_rejected,create_allocates_monotonic_sequence_and_sort_order,list_returns_visible_items_newest_first(was..._in_sequence_order),soft_delete_hides_rows_and_never_reuses_sequence_ids,cross_tenant_access_is_rejected_and_has_no_effect,non_members_and_guests_are_forbidden_to_write,external_id_is_unique_among_live_rows_only,concurrent_creates_never_duplicate_a_sequence_id,invalid_input_is_a_client_error, and the control ofreset_requires_the_admin_token_and_a_refused_call_deletes_nothing. Each keeps its controls.tests/auth/mod.rs: the two slice key tests that assert an exact listing count only the keys they made (made_here), becauseGET /api-keyslists the fixture's key like any other.budget/mod.rs,bench_scale.rs: akeyfield on the users they build by hand.by-change.mdthat said nothing is served under/api/v1.What the tests say now (v1's answers, not the slice's)
A stranger and a project that is not there are a 403 (the slice said 404 and told them apart from a member who is not in the project); a list is newest first; the first work item of a state is at 65535 and the next 10000 after it (the slice: 10000 steps); a member deletes only what they made (403
Only admin or creator can delete the work item), a guest nothing; a taken external key is a 409 naming the work item; a bad body is a 400 in DRF's words; a missing key is a 401, a key that is not valid a 403Given API token is not valid, and a session token is no key.Things I left out on purpose, for you to check
scope=with_deletedand the 400 for an unknown scope go with the slice:/api/v1has no view of a deleted row. Core still has the behaviour and its own tests; nothing tests it over HTTP now.sort_orderuniqueness under concurrent creates is no longer asserted. The pin reads the greatestsort_orderbefore it inserts, so two creates at once can share a place; the sequence numbers are still checked to be unique and contiguous.65535), and the compat tests seed their own default state per project, which a default in the shared fixture replaced (one of them failed on it).Evidence (2026-11-11, local)
scripts/contract.sh <target> mainonnative-memory,native-pg,worker-memoryandworker-cf: 57 passed, 57 expected, on each (the count is unchanged: ten replaced by ten).scripts/mutants.sh's mutants, run by hand for the two these tests answer for):ignore-tenantfails 6 tests, among them the migratedcross_tenant_access_is_rejected_and_has_no_effect;duplicate-sequence-numberfails 6, among them the migrated create, list, soft-delete and concurrent-create tests.cargo fmt --all --checkandcargo clippy -p thrust-contract-tests --all-targets -- -D warnings: clean.scripts/mutants.sh; themutantsjob runs them.Not done (next stages, G-26)
Still on
/api/_slice: sign-out and sign-out-everywhere, the session info, OIDC, API-key creation, listing and revocation (no route replaces them: the compat plane has sign-in, sign-up, the email check and the CSRF token only), the activity feeds, attachments, and the tests that use a slice work item as their vehicle: the model and the access matrices, the engine tests, the outbox, redelivery, sweeper and panic tests, the create limit, the cookie and CSRF tests, the bench. Then the slice's routes,SLICE_PREFIX, the test that shows the prefix is gone, and the core, port and adapter code that only the slice used.🤖 Generated with Claude Code