
























@@ -86,4 +86,73 @@ describe("status.scan.config-shared", () => {
8686secretDiagnostics: ["resolved"],
8787});
8888});
89+90+it("adds a status diagnostic for gateway token source conflicts", async () => {
91+const sourceConfig = { gateway: { auth: { token: "config-token" } } };
92+const resolvedConfig = sourceConfig;
93+const readBestEffortConfig = vi.fn(async () => sourceConfig);
94+const resolveConfig = vi.fn(async () => ({
95+ resolvedConfig,
96+diagnostics: [],
97+}));
98+99+const result = await loadStatusScanCommandConfig({
100+commandName: "status --json",
101+ readBestEffortConfig,
102+ resolveConfig,
103+env: { VITEST: "true", OPENCLAW_GATEWAY_TOKEN: "env-token" },
104+allowMissingConfigFastPath: true,
105+});
106+107+expect(result.secretDiagnostics).toEqual([
108+expect.stringContaining("OPENCLAW_GATEWAY_TOKEN overrides gateway.auth.token"),
109+]);
110+});
111+112+it("does not add a status diagnostic when config uses OPENCLAW_GATEWAY_TOKEN", async () => {
113+const sourceConfig = {
114+gateway: { auth: { token: "${OPENCLAW_GATEWAY_TOKEN}" } },
115+secrets: { providers: { default: { source: "env" as const } } },
116+};
117+const readBestEffortConfig = vi.fn(async () => sourceConfig);
118+const resolveConfig = vi.fn(async () => ({
119+resolvedConfig: sourceConfig,
120+diagnostics: [],
121+}));
122+123+const result = await loadStatusScanCommandConfig({
124+commandName: "status --json",
125+ readBestEffortConfig,
126+ resolveConfig,
127+env: { VITEST: "true", OPENCLAW_GATEWAY_TOKEN: "env-token" },
128+allowMissingConfigFastPath: true,
129+});
130+131+expect(result.secretDiagnostics).toEqual([]);
132+});
133+134+it("does not add a status diagnostic for remote gateway mode", async () => {
135+const sourceConfig = {
136+gateway: {
137+mode: "remote" as const,
138+remote: { token: "remote-token" },
139+auth: { token: "local-token" },
140+},
141+};
142+const readBestEffortConfig = vi.fn(async () => sourceConfig);
143+const resolveConfig = vi.fn(async () => ({
144+resolvedConfig: sourceConfig,
145+diagnostics: [],
146+}));
147+148+const result = await loadStatusScanCommandConfig({
149+commandName: "status --json",
150+ readBestEffortConfig,
151+ resolveConfig,
152+env: { VITEST: "true", OPENCLAW_GATEWAY_TOKEN: "env-token" },
153+allowMissingConfigFastPath: true,
154+});
155+156+expect(result.secretDiagnostics).toEqual([]);
157+});
89158});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。