MCPcopy
hub / github.com/fosrl/pangolin / runTests

Function runTests

server/routers/resource/inlinePolicyFields.test.ts:4–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { applyInlinePolicyFields } from "./inlinePolicyFields";
3
4function runTests() {
5 const resource = {
6 resourceId: 1,
7 name: "dashboard",
8 sso: null,
9 emailWhitelistEnabled: null,
10 applyRules: null,
11 skipToIdpId: null
12 } as any;
13
14 const enabledPolicy = {
15 sso: true,
16 emailWhitelistEnabled: true,
17 applyRules: true,
18 idpId: 42
19 };
20
21 const enabledResult = applyInlinePolicyFields(resource, enabledPolicy);
22 assertEquals(enabledResult.sso, true, "sso should mirror policy true");
23 assertEquals(
24 enabledResult.emailWhitelistEnabled,
25 true,
26 "email whitelist should mirror policy true"
27 );
28 assertEquals(
29 enabledResult.applyRules,
30 true,
31 "applyRules should mirror policy true"
32 );
33 assertEquals(
34 enabledResult.skipToIdpId,
35 42,
36 "skipToIdpId should use policy idpId"
37 );
38
39 const disabledPolicy = {
40 sso: false,
41 emailWhitelistEnabled: false,
42 applyRules: false,
43 idpId: null
44 };
45
46 const disabledResult = applyInlinePolicyFields(resource, disabledPolicy);
47 assertEquals(disabledResult.sso, false, "sso false must not become null");
48 assertEquals(
49 disabledResult.emailWhitelistEnabled,
50 false,
51 "email whitelist false must not become null"
52 );
53 assertEquals(
54 disabledResult.applyRules,
55 false,
56 "applyRules false must not become null"
57 );
58 assertEquals(
59 disabledResult.skipToIdpId,
60 null,
61 "missing idp should stay null"

Callers 1

Calls 2

applyInlinePolicyFieldsFunction · 0.90
assertEqualsFunction · 0.90

Tested by

no test coverage detected