





















@@ -1,4 +1,5 @@
11import { afterEach, describe, expect, it, vi } from "vitest";
2+import { loadAuthProfileStoreWithoutExternalProfiles } from "../agents/auth-profiles.js";
23import type { ConfigFileSnapshot, OpenClawConfig } from "../config/types.js";
34import type { PreparedSecretsRuntimeSnapshot, SecretResolverWarning } from "../secrets/runtime.js";
45import { KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS } from "./known-weak-gateway-secrets.js";
@@ -105,6 +106,30 @@ describe("gateway startup config secret preflight", () => {
105106expect(emitStateEvent).not.toHaveBeenCalled();
106107});
107108109+it("uses persisted auth stores only for startup secret preflight", async () => {
110+const prepareRuntimeSecretsSnapshot = vi.fn(async ({ config }) => preparedSnapshot(config));
111+const activateRuntimeSecrets = createRuntimeSecretsActivator({
112+logSecrets: {
113+info: vi.fn(),
114+warn: vi.fn(),
115+error: vi.fn(),
116+},
117+emitStateEvent: vi.fn(),
118+ prepareRuntimeSecretsSnapshot,
119+activateRuntimeSecretsSnapshot: vi.fn(),
120+});
121+122+await activateRuntimeSecrets(gatewayTokenConfig({}), {
123+reason: "startup",
124+activate: false,
125+});
126+127+expect(prepareRuntimeSecretsSnapshot).toHaveBeenCalledWith({
128+config: expect.any(Object),
129+loadAuthStore: loadAuthProfileStoreWithoutExternalProfiles,
130+});
131+});
132+108133it("does not emit degraded or recovered events for warning-only secret reloads", async () => {
109134const warning: SecretResolverWarning = {
110135code: "WEB_SEARCH_KEY_UNRESOLVED_FALLBACK_USED",
@@ -156,6 +181,9 @@ describe("gateway startup config secret preflight", () => {
156181"[WEB_SEARCH_KEY_UNRESOLVED_FALLBACK_USED] web search provider fell back to environment credentials",
157182);
158183expect(emitStateEvent).not.toHaveBeenCalled();
184+expect(prepareRuntimeSecretsSnapshot).toHaveBeenCalledWith({
185+config: expect.any(Object),
186+});
159187});
160188161189it.each(KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS)(
@@ -245,6 +273,7 @@ describe("gateway startup config secret preflight", () => {
245273config: expect.not.objectContaining({
246274channels: expect.anything(),
247275}),
276+loadAuthStore: loadAuthProfileStoreWithoutExternalProfiles,
248277});
249278});
250279@@ -294,6 +323,7 @@ describe("gateway startup config secret preflight", () => {
294323}),
295324}),
296325}),
326+loadAuthStore: loadAuthProfileStoreWithoutExternalProfiles,
297327});
298328expect(activateRuntimeSecretsSnapshot).toHaveBeenCalledTimes(1);
299329});
@@ -327,6 +357,7 @@ describe("gateway startup config secret preflight", () => {
327357}),
328358}),
329359}),
360+loadAuthStore: loadAuthProfileStoreWithoutExternalProfiles,
330361});
331362});
332363此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。