Skip to content

Commit 1c6ee7f

Browse files
committed
test(dogfood): sweep and drive the SCIM credential door on the composed runtime
Claude-Session: https://claude.ai/code/session_016WV4cycHNJyS5MXHqaGsFE Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 70847b8 commit 1c6ee7f

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

‎packages/qa/dogfood/test/admin-identity-audit-trail.dogfood.test.ts‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,85 @@ describe('#4940: what an admin identity operation leaves in sys_audit_log', () =
256256
expect(metadata).toMatchObject({ total: 1, created: 1, updated: 0, skipped: 0, errors: 0 });
257257
expect(metadata.delivery).toMatchObject({ temporary: 1 });
258258
}, 120_000);
259+
260+
// ── W5 (#30958): the SCIM credential door, on the composed runtime ──────
261+
//
262+
// The platform admin mints a SCIM connection bearer, an identity provider
263+
// provisions with it, the admin revokes it and the next provisioning call is
264+
// refused. Then the secret is looked for everywhere this stack keeps or
265+
// serves: the bearer must appear ONLY in the mint's own answer, and its
266+
// keyed digest only in its own column at rest — never in a `sys_audit_log`
267+
// row (the door's explicit rows AND plugin-audit's generic ones for the
268+
// credential writes), never in `sys_activity`, never in the data API's list
269+
// or export of the credential object.
270+
271+
it('POST /admin/scim/mint-credential + revoke-credential: the bearer provisions, is refused once revoked, and is shown nowhere else', async () => {
272+
const minted = await stack.apiAs(adminToken, 'POST', '/auth/admin/scim/mint-credential', {
273+
connectionId: 'okta-dogfood-30958',
274+
});
275+
expect(minted.status, await minted.clone().text()).toBe(200);
276+
expect(minted.headers.get('cache-control')).toBe('no-store');
277+
const { token, credentialId } = (await minted.json()).data as { token: string; credentialId: string };
278+
279+
const provision = (localPart: string) =>
280+
stack.api('/auth/scim/v2/Users', {
281+
method: 'POST',
282+
headers: { authorization: `Bearer ${token}`, 'content-type': 'application/scim+json' },
283+
body: JSON.stringify({
284+
schemas: ['urn:ietf:params:scim:schemas:core:2.0:User'],
285+
userName: `${localPart}@example.com`,
286+
name: { givenName: localPart, familyName: 'Dogfood' },
287+
emails: [{ value: `${localPart}@example.com`, primary: true, type: 'work' }],
288+
active: true,
289+
}),
290+
});
291+
const created = await provision('scim-provisioned-30958');
292+
expect(created.status, await created.clone().text()).toBe(201);
293+
294+
const revoked = await stack.apiAs(adminToken, 'POST', '/auth/admin/scim/revoke-credential', { credentialId });
295+
expect(revoked.status, await revoked.clone().text()).toBe(200);
296+
const refused = await provision('scim-after-revoke-30958');
297+
expect(refused.status, await refused.clone().text()).toBe(401);
298+
299+
// The digest as stored, read below the engine (the engine never serves it).
300+
const driver = ql.getDriver?.('sys_scim_connection_credential');
301+
expect(driver, 'no driver read for the credential object').toBeTruthy();
302+
const atRest = (await driver.find('sys_scim_connection_credential', { where: { id: credentialId } })) as any[];
303+
const digest = String(atRest[0]?.token_digest ?? '');
304+
expect(digest.length, 'the credential row holds no digest at rest').toBeGreaterThan(20);
305+
expect(JSON.stringify(atRest[0])).not.toContain(token);
306+
307+
// The door's explicit rows: one per mint and per revoke, naming the admin and the connection.
308+
const explicit = await waitForRows(
309+
async () => (await findRows(ql, 'sys_audit_log', { object_name: 'sys_scim_connection_credential', record_id: credentialId }))
310+
.filter((r) => !isGeneric(r)),
311+
(rows) => rows.length === 2,
312+
'the mint and revoke rows',
313+
);
314+
expect(explicit.map((r) => JSON.parse(String(r.metadata)).event).sort())
315+
.toEqual(['scim_credential_minted', 'scim_credential_revoked']);
316+
for (const row of explicit) {
317+
expect(row.user_id).toBe(adminUserId);
318+
expect(JSON.parse(String(row.metadata)).connectionId).toBe('okta-dogfood-30958');
319+
}
320+
321+
// Nowhere else: every ledger row, the activity feed, and the data API's reads.
322+
const ledgers = JSON.stringify([
323+
await findRows(ql, 'sys_audit_log', {}, 5000),
324+
...(ql.getSchema?.('sys_activity') ? [await findRows(ql, 'sys_activity', {}, 5000)] : []),
325+
]);
326+
expect(ledgers).not.toContain(token);
327+
expect(ledgers).not.toContain(digest);
328+
const list = await stack.apiAs(adminToken, 'GET', '/data/sys_scim_connection_credential');
329+
const listed = await list.text();
330+
expect(list.status, listed).toBe(200);
331+
expect(listed).toContain(credentialId);
332+
const exported = await stack.apiAs(adminToken, 'GET', '/data/sys_scim_connection_credential/export');
333+
const exportedText = await exported.text();
334+
expect(exported.status, exportedText.slice(0, 300)).toBe(200);
335+
for (const served of [listed, exportedText]) {
336+
expect(served).not.toContain(token);
337+
expect(served).not.toContain(digest);
338+
}
339+
}, 120_000);
259340
});

‎packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,24 @@ function expectationsFor(targetUserId: string): Record<string, RouteExpectation>
283283
bucket: 'objectstack-gate',
284284
note: 'a read: the gate runs first and the handler reads no body and no query parameter; the admin gets 200 { clientAddress, trustProxy }',
285285
},
286+
// ── #30958 — the SCIM connection-credential door (mint + revoke) ────────
287+
//
288+
// Both mounts run `gateAdmin(c)` as their first statement, ahead of any body
289+
// read, so anon 401 / member 403 hold on any body. The admin side on these
290+
// payloads: SCIM is on in this boot (OS_SCIM_ENABLED, beforeAll), so the
291+
// mint answers 200 with a fresh credential for a probe connection nothing
292+
// provisions through (the sweep's own stack, discarded at teardown), and
293+
// the revoke lands on 404 RESOURCE_NOT_FOUND for the unknown credential.
294+
'POST /api/v1/auth/admin/scim/mint-credential': {
295+
bucket: 'objectstack-gate',
296+
body: { connectionId: 'refusal-probe-scim' },
297+
note: 'the gate runs ahead of any body read; the admin gets 200 and a credential for the probe connection, since SCIM is on in this boot',
298+
},
299+
'POST /api/v1/auth/admin/scim/revoke-credential': {
300+
bucket: 'objectstack-gate',
301+
body: { credentialId: 'refusal-probe-credential' },
302+
note: 'the gate runs ahead of any body read; the admin passes it and lands on 404 RESOURCE_NOT_FOUND for the unknown credential',
303+
},
286304
// ── #9653: the /admin/sso/* bridges, gated ahead of their delegation ────
287305
//
288306
// The ADR-0068 gate runs BEFORE the bridge re-dispatches into better-auth,

0 commit comments

Comments
 (0)