MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / createPolicyClient

Function createPolicyClient

tests/e2e/orm/policy/raw-sql.test.ts:39–57  ·  view source on GitHub ↗
(options?: { dangerouslyAllowRawSql?: boolean; dbName: string })

Source from the content-addressed store, hash-verified

37 }
38
39 async function createPolicyClient(options?: { dangerouslyAllowRawSql?: boolean; dbName: string }) {
40 const unsafeClient = await createTestClient(schema, {
41 dbName: options?.dbName,
42 plugins: [new PolicyPlugin({ dangerouslyAllowRawSql: options?.dangerouslyAllowRawSql })],
43 });
44 clients.push(unsafeClient);
45
46 const rawClient = unsafeClient.$unuseAll();
47 const adminClient = unsafeClient.$setAuth({ id: 'admin', role: 'admin' });
48
49 await rawClient.user.create({
50 data: {
51 id: 'admin',
52 role: 'admin',
53 },
54 });
55
56 return { adminClient };
57 }
58
59 it('keeps rejecting raw SQL by default', async () => {
60 const { adminClient } = await createPolicyClient({ dbName: 'policy_raw_sql_default' });

Callers 1

raw-sql.test.tsFile · 0.85

Calls 4

createTestClientFunction · 0.90
pushMethod · 0.80
$unuseAllMethod · 0.80
$setAuthMethod · 0.80

Tested by

no test coverage detected