Skip to content

Commit 0367cb1

Browse files
committed
test(service-automation): type the sys_user default pin's query options and security service lookup
Claude-Session: https://claude.ai/code/session_01FatVyDAFEST48jZDQcbheU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 41cd5e4 commit 0367cb1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎packages/services/service-automation/src/sys-user-default-row-scope.integration.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ describe("sys_user's one `||` default keeps the reader's own row on every user-c
214214
for (const literal of SHIPPED_LITERALS) {
215215
const where = compiler.compileFilter([literal as any], context as any);
216216
if (where === null) throw new Error(`literal ${literal.name} compiled to no filter`);
217-
for (const id of ids(await ql.find('sys_user', { where, fields: ['id'], context: SYS } as any))) out.add(id);
217+
for (const id of ids(await ql.find('sys_user', { where, fields: ['id'], context: SYS }))) out.add(id);
218218
}
219219
return [...out].sort();
220220
}
@@ -248,9 +248,10 @@ describe("sys_user's one `||` default keeps the reader's own row on every user-c
248248
it('CONTROL: the rows are the object default\'s — explain names it, and a system read sees all four users', async () => {
249249
await boot();
250250
expect(ids(await ql.find('sys_user', { context: SYS }))).toEqual(['usr_loner', 'usr_me', 'usr_other', 'usr_peer']);
251-
const security = kernel.getService<any>('security');
251+
type Explained = { layers: Array<{ layer: string; verdict: string; detail: string }> };
252+
const security = kernel.getService<{ explain(input: { object: string; operation: string }, context: object): Promise<Explained> }>('security');
252253
const decision = await security.explain({ object: 'sys_user', operation: 'read' }, await requestContext('usr_me', orgA));
253-
const rls = (decision.layers as Array<{ layer: string; verdict: string; detail: string }>).find((l) => l.layer === 'rls');
254+
const rls = decision.layers.find((l) => l.layer === 'rls');
254255
expect(rls?.verdict).toBe('narrows');
255256
expect(rls?.detail).toContain("'sys_user_self_or_org_members'");
256257
expect(rls?.detail).toContain('object default row scope');

0 commit comments

Comments
 (0)