Skip to content

Commit 2deb9e3

Browse files
committed
test(plugin-security): type the reader's read options in the person-title pin instead of erasing them
check:query-options-erasure counted three erased option bags (236 to 239). Claude-Session: https://claude.ai/code/session_011TdZ8GjixNZFLz1xJD9zzK Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9ffef3b commit 2deb9e3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎packages/plugins/plugin-security/src/objects/sys-user-permission-set-person-title.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ import {
4242
import { SqlDriver } from '@objectstack/driver-sql';
4343
import { SysUser } from '@objectstack/platform-objects';
4444
import { resolveDisplayField, resolveRecordDisplayName } from '@objectstack/spec/data';
45+
import type { ExecutionContext } from '@objectstack/spec/kernel';
4546
import { SysUserPermissionSet } from './sys-user-permission-set.object.js';
4647

4748
const SYS = { context: { isSystem: true } } as any;
4849
const OBJECT = 'sys_user_permission_set';
4950

5051
/** A reader who is not SYSTEM: the shape every request's context has. */
51-
const READER = { userId: 'usr_reader', tenantId: 'org_1' };
52+
const READER: ExecutionContext = { userId: 'usr_reader', tenantId: 'org_1' };
5253

5354
/** Every `record.<path>` the `display_title` expression reads, as written. */
5455
function formulaReads(): string[] {
@@ -152,17 +153,17 @@ describe('sys_user_permission_set is titled by the person, not the raw user id',
152153
const bob = await user('Bob Kinney', 'bob@example.com');
153154
const g = await grant(bob);
154155
readable.add(bob);
155-
const row = await engine.findOne(OBJECT, { where: { id: g.id } }, { context: READER } as any);
156+
const row = await engine.findOne(OBJECT, { where: { id: g.id } }, { context: READER });
156157
expect(row!.display_title).toBe('Bob Kinney → crm_edit');
157158
});
158159

159160
it('a user the reader may not read leaves the title null, and nothing of the user reaches the row', async () => {
160161
const carol = await user('Carol Hidden', 'carol.hidden@example.com');
161162
const g = await grant(carol);
162163
// The reader's own read of that user returns nothing…
163-
expect(await engine.find('sys_user', { where: { id: carol } }, { context: READER } as any)).toEqual([]);
164+
expect(await engine.find('sys_user', { where: { id: carol } }, { context: READER })).toEqual([]);
164165
// …so the title over it has no value, and neither the name nor the email leaks.
165-
const row = await engine.findOne(OBJECT, { where: { id: g.id } }, { context: READER } as any);
166+
const row = await engine.findOne(OBJECT, { where: { id: g.id } }, { context: READER });
166167
expect(row!.display_title).toBeNull();
167168
expect(JSON.stringify(row)).not.toContain('Carol Hidden');
168169
expect(JSON.stringify(row)).not.toContain('carol.hidden@example.com');

0 commit comments

Comments
 (0)