Skip to content

Commit ede1fbd

Browse files
committed
test(service-automation): the SecurityPlugin flip rig holds the Default Organization, the member's own
The rig composes the identity objects (so `sys_organization` is registered) and no auth plugin, then runs a user-less system flow whose `create_record` is a system insert into a tenant-scoped object: refused under ADR-0131 C1 (D9, `no-organization`), a shape no production `single` boot reaches. The rig now seeds the Default Organization as `org_1`, the member's organization, and the NULL-born case pins the row's derived organization so the 403 is decided by the stamp columns alone. The lean rig above (no organization object) is unchanged. Claude-Session: https://claude.ai/code/session_01EUBvqtauTDmHi2ZgY759p2 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b7d0b34 commit ede1fbd

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎packages/services/service-automation/src/runas-system-stamping.integration.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ describe('the #5494 admission flip: row content, not caller, decides (real Secur
263263
ql.registerDriver(driver, true);
264264
ql.registry.registerObject(crmTask as any, 'stamping-test', 'stamping-test');
265265
await ql.syncSchemas();
266+
// [ADR-0131 D3] A production `single` boot holds the Default Organization
267+
// before any flow runs: the auth plugin's boot invariant, which this rig
268+
// (identity objects, no auth plugin) does not compose. It is the member's
269+
// organization, `org_1`, the deployment's one organization. Without it the
270+
// user-less run's system insert is refused (D9): this composition
271+
// registers `sys_organization`, and the install would hold none.
272+
await ql.insert(
273+
'sys_organization',
274+
{ id: 'org_1', name: 'Default Organization', slug: 'default' },
275+
{ context: { isSystem: true } },
276+
);
266277
}
267278

268279
const SYS = { isSystem: true } as const;
@@ -304,6 +315,10 @@ describe('the #5494 admission flip: row content, not caller, decides (real Secur
304315
expect(res.success).toBe(true);
305316
const row = await rowByTitle('flip B');
306317
expect(row!.created_by ?? null).toBeNull();
318+
// [ADR-0131 D9] The user-less system insert derives the install's one
319+
// organization, the member's own, so the denial below is decided by the
320+
// stamp columns alone and not by an organization boundary.
321+
expect(row!.organization_id).toBe('org_1');
307322

308323
// The SAME member context that succeeded above is denied here: the only
309324
// difference between the two attempts is the row's stamp columns — the

0 commit comments

Comments
 (0)