The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { ProviderDriverKind, type ManagedPolicySummary } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { managedInstanceLocks } from "./managedPolicy"; |
| 5 | |
| 6 | const codex = ProviderDriverKind.make("codex"); |
| 7 | const claude = ProviderDriverKind.make("claudeAgent"); |
| 8 | |
| 9 | const policy: ManagedPolicySummary = { |
| 10 | organization: "Example Corp", |
| 11 | lockedSettings: [], |
| 12 | limits: { |
| 13 | providers: { |
| 14 | lockedInstanceFields: { |
| 15 | [codex]: ["config.binaryPath", "environment.OPENAI_BASE_URL", "environment.HTTPS_PROXY"], |
| 16 | }, |
| 17 | }, |
| 18 | }, |
| 19 | }; |
| 20 | |
| 21 | describe("managedInstanceLocks", () => { |
| 22 | it("splits locked instance paths into config keys and environment names", () => { |
| 23 | const locks = managedInstanceLocks(policy, codex); |
| 24 | expect(locks && [...locks.configKeys]).toEqual(["binaryPath"]); |
| 25 | expect(locks && [...locks.environmentNames]).toEqual(["OPENAI_BASE_URL", "HTTPS_PROXY"]); |
| 26 | expect(locks?.reason).toBe("Managed by Example Corp."); |
| 27 | }); |
| 28 | |
| 29 | it("treats a bare environment path as every variable", () => { |
| 30 | const ceilingPolicy = { |
| 31 | ...policy, |
| 32 | limits: { |
| 33 | providers: { lockedInstanceFields: { [codex]: ["config.binaryPath", "environment"] } }, |
| 34 | }, |
| 35 | }; |
| 36 | const locks = managedInstanceLocks(ceilingPolicy, codex); |
| 37 | expect(locks?.wholeEnvironment).toBe(true); |
| 38 | expect(managedInstanceLocks(policy, codex)?.wholeEnvironment).toBe(false); |
| 39 | }); |
| 40 | |
| 41 | it("locks nothing for drivers the policy does not pin, or without a policy", () => { |
| 42 | expect(managedInstanceLocks(policy, claude)).toBeUndefined(); |
| 43 | expect(managedInstanceLocks(undefined, codex)).toBeUndefined(); |
| 44 | }); |
| 45 | }); |