Skip to content

Commit d813364

Browse files
committed
test(rest): the PUT door's query-smuggled organization id is now a located 400
The census caller: the pin sent an inert ?organizationId= that PUT never read; the door's closed set refuses it, so the pin splits into the body half (still 200, nothing reaches the save) and the query half (400, nothing written). Claude-Session: https://claude.ai/code/session_01VoSxBQujKLZKPwK2u5ehQ6 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 52b332b commit d813364

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎packages/rest/src/meta-item-save-capability-gate.test.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,29 @@ describe('ADR-0131 D6 — PUT /meta/:type/:name: an organization admin\'s metada
367367
expect('organizationId' in stack.saveMetaItem.mock.calls[0][0]).toBe(false);
368368
});
369369

370-
it('query/body-smuggled organization ids do not reach the write either', async () => {
370+
it('a body-smuggled organization id does not reach the write either', async () => {
371371
const stack = bootDoor({ userId: 'u_author', systemPermissions: ['manage_metadata'], tenantId: ORG });
372372
const write = await stack.put(
373373
'view', 'org_grid',
374374
{ name: 'org_grid', organization_id: 'org_b', organizationId: 'org_b' },
375-
{ organizationId: 'org_b' },
376375
);
377376
expect(write.res.statusCode).toBe(200);
378377
// The save request is built field by field from named `req` values.
379378
expect('organizationId' in stack.saveMetaItem.mock.calls[0][0]).toBe(false);
380379
});
381380

381+
// [#23072] The query half used to be the same 200 with the name dropped.
382+
// The door now declares its closed set (`force`, `package`, `mode`), so a
383+
// query-smuggled organization id is refused before anything is written.
384+
it('a query-smuggled organization id is refused with a located 400, and nothing is written', async () => {
385+
const stack = bootDoor({ userId: 'u_author', systemPermissions: ['manage_metadata'], tenantId: ORG });
386+
const write = await stack.put('view', 'org_grid', { name: 'org_grid' }, { organizationId: 'org_b' });
387+
expect(write.res.statusCode).toBe(400);
388+
expect(write.body?.error?.code).toBe('VALIDATION_ERROR');
389+
expect(write.body?.error?.message).toMatch(/^The "organizationId" query parameter is not supported by this endpoint\./);
390+
expect(stack.saveMetaItem).not.toHaveBeenCalled();
391+
});
392+
382393
it('control: `manage_metadata` with no active organization still saves a view env-wide, as before', async () => {
383394
const stack = bootDoor({ userId: 'u_author', systemPermissions: ['manage_metadata'] });
384395
const write = await stack.put('view', 'org_grid', { name: 'org_grid' });

0 commit comments

Comments
 (0)