Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

policyTemplates.test.ts

60 lines2.0 KB

1import { assert, it } from "@effect/vitest";
2import { ProviderDriverKind } from "@t3tools/contracts";
3import {
4 WINDOWS_POLICY_GROUPS,
5 WINDOWS_POLICY_LISTS,
6 WINDOWS_POLICY_VALUES,
7} from "@t3tools/shared/managedPolicyFile";
8​
9import { macosProfile, windowsAdmx } from "./policyTemplates.ts";
10​
11it("gives every registry value the Windows reader accepts a Group Policy control", () => {
12 const admx = windowsAdmx();
13 for (const name of Object.keys(WINDOWS_POLICY_VALUES)) {
14 assert.include(admx, `valueName="${name}"`);
15 }
16 for (const key of Object.keys(WINDOWS_POLICY_LISTS)) {
17 assert.include(admx, `key="SOFTWARE\\Policies\\T3Tools\\T3Code\\${key}"`);
18 }
19 for (const name of Object.keys(WINDOWS_POLICY_GROUPS)) {
20 assert.include(admx, `valueName="${name}"`);
21 }
22});
23​
24it("refuses a profile for a policy with a null value, which a plist cannot hold", () => {
25 const profile = macosProfile(
26 {
27 schemaVersion: 1,
28 organization: "Example Corp",
29 settings: { defaultModelSelection: { value: null, locked: true } },
30 },
31 { profile: "profile-uuid", payload: "payload-uuid" },
32 );
33 assert.deepStrictEqual(profile, {
34 _tag: "Invalid",
35 reason:
36 "settings.defaultModelSelection is null, which a configuration profile cannot hold; deploy this policy as a file.",
37 });
38});
39​
40it("keeps carriage returns in the macOS profile's provider environment strings", () => {
41 const profile = macosProfile(
42 {
43 schemaVersion: 1,
44 organization: "Example Corp",
45 limits: {
46 providers: {
47 instances: {
48 [ProviderDriverKind.make("claudeAgent")]: {
49 locked: true,
50 environment: [{ name: "EXAMPLE_PAYLOAD", value: "first\r\nsecond\rthird\n<&>" }],
51 },
52 },
53 },
54 },
55 },
56 { profile: "profile-uuid", payload: "payload-uuid" },
57 );
58 assert(profile._tag === "Valid");
59 assert.include(profile.profile, "<string>first&#13;\nsecond&#13;third\n&lt;&amp;&gt;</string>");
60});