Skip to content

Commit 82757fb

Browse files
matt-aitkenclaude
andcommitted
test(webapp): delete dead authorization.test.ts, update batch e2e to match backwards-compat fix
Two CI failures on PR #3499: 1. Shard 7 — `test/authorization.test.ts` failed at module load with "Cannot find module '../app/services/authorization.server'". That module was deleted in 18e0701 (the entire `checkAuthorization` function went with the apiBuilder migration), but I missed the test file that exercised it — the earlier grep for live consumers only walked `app/`, not `test/`. The test was unit coverage for the now-deleted function; nothing else worth saving in it. Delete. 2. E2E auth — `JWT read:runs: 403 (resource type is 'batch', not 'runs')` was asserting the strict-match behaviour that 9f987ae deliberately reverted for backwards compat (batch retrieve routes wrap `{type: "batch", id}` in anyResource([...]) alongside `{type: "runs"}` so JWTs minted with read:runs against batch endpoints keep working). The test caught my own intentional change. Update the expectation: `read:runs` JWT should now pass (not be 403), and rename the test to reflect the new behaviour with a comment pointing at the backwards-compat rationale. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 704b072 commit 82757fb

2 files changed

Lines changed: 11 additions & 431 deletions

File tree

apps/webapp/test/auth-api.e2e.full.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,21 +1681,24 @@ describe("API", () => {
16811681
expect(res.status).not.toBe(403);
16821682
});
16831683

1684-
it("JWT read:runs: 403 (resource type is 'batch', not 'runs')", async () => {
1684+
it("JWT read:runs: auth passes (backwards-compat for legacy SDKs)", async () => {
16851685
const { batchFriendlyId, apiKey, environment } = await seedRunWithBatch();
16861686
const jwt = await generateJWT({
16871687
secretKey: apiKey,
16881688
payload: { pub: true, sub: environment.id, scopes: ["read:runs"] },
16891689
expirationTime: "15m",
16901690
});
16911691
const res = await get(pathFor(batchFriendlyId), { Authorization: `Bearer ${jwt}` });
1692-
// Pre-TRI-8719 the legacy literal-match escape granted
1693-
// read:runs access to batch endpoints. Post-migration the
1694-
// resource type is strictly { type: "batch" } and read:runs
1695-
// doesn't match. Lock this in — if SDKs were issuing
1696-
// read:runs:* JWTs for batch lookups, that's a regression to
1697-
// catch.
1698-
expect(res.status).toBe(403);
1692+
// Pre-RBAC the batch-retrieve route's superScopes included
1693+
// `read:runs`, so JWTs minted with read:runs could read batches.
1694+
// The post-migration backwards-compat fix adds a `{type: "runs"}`
1695+
// element to the route's anyResource(...) list so those
1696+
// SDK-issued JWTs in the wild keep working — avoids a silent
1697+
// 401/403 regression for callers we never told to switch scopes.
1698+
// Per-id `read:batch:<id>` and type-level `read:batch` still
1699+
// grant via the route's first resource element.
1700+
expect(res.status).not.toBe(401);
1701+
expect(res.status).not.toBe(403);
16991702
});
17001703

17011704
it("JWT read:all super-scope: auth passes", async () => {

0 commit comments

Comments
 (0)