Open History to see the last commit
1import { ServerSettings } from "@t3tools/contracts";
2import * as Schema from "effect/Schema";
3import { expect, it } from "vite-plus/test";
4
5import { secretProviderUses } from "./SecretsSettings.logic";
6
7const personal = (reference: string) => ({ provider: "personal", reference });
8const work = { provider: "work", reference: "op://Work/token" };
9
10const settings = Schema.decodeSync(ServerSettings)({
11 providerInstances: {
12 antigravity_work: {
13 driver: "antigravity",
14 displayName: "Antigravity Work",
15 environment: [
16 { name: "API_TOKEN", value: "", secret: personal("op://a/env") },
17 { name: "OTHER_TOKEN", value: "", secret: work },
18 ],
19 },
20 codex_plain: {
21 driver: "codex",
22 environment: [{ name: "CODEX_TOKEN", value: "", secret: personal("op://c/env") }],
23 },
24 },
25 sourceControlHosts: {
26 github: { tokens: { "github.com": personal("op://gh"), "ghe.acme.test": work } },
27 },
28 usageLimitSources: {
29 hub: { kind: "cliproxy", url: "https://hub.test", managementKey: personal("op://hub") },
30 },
31 easDeviceHosts: [
32 { kind: "eas", id: "eas", label: "EAS Simulator", accessToken: personal("op://expo") },
33 ],
34 simlockDeviceHosts: [
35 {
36 kind: "simlock",
37 id: "pool",
38 label: "Simlock Pool",
39 gatewayUrl: "https://simlock.test",
40 agentToken: personal("op://simlock"),
41 },
42 ],
43 cloudSpeechCredentials: { openai: personal("op://voice"), xai: "" },
44});
45
46it.each([
47 [
48 "personal",
49 [
50 "Antigravity Work · API_TOKEN",
51 "Codex · CODEX_TOKEN",
52 "GitHub · github.com",
53 "https://hub.test · Management Key",
54 "EAS Simulator · Access Token",
55 "Simlock Pool · Agent Token",
56 "Voice · OpenAI",
57 ],
58 ],
59 ["work", ["Antigravity Work · OTHER_TOKEN", "GitHub · ghe.acme.test"]],
60 ["unused", []],
61])("lists what reads from secret provider %s", (providerId, uses) => {
62 expect(secretProviderUses(settings, providerId).map((use) => use.label)).toEqual(uses);
63});