























@@ -1,8 +1,10 @@
1-import { describe, expect, it, vi } from "vitest";
1+import { beforeEach, describe, expect, it, vi } from "vitest";
22import type { OpenClawConfig } from "../config/types.openclaw.js";
3344const storeMocks = vi.hoisted(() => ({
55ensureAuthProfileStore: vi.fn(() => ({ version: 1, profiles: {} })),
6+ensureAuthProfileStoreWithoutExternalProfiles: vi.fn(() => ({ version: 1, profiles: {} })),
7+loadAuthProfileStoreWithoutExternalProfiles: vi.fn(() => ({ version: 1, profiles: {} })),
68loadAuthProfileStoreForRuntime: vi.fn(() => ({ version: 1, profiles: {} })),
79loadAuthProfileStoreForSecretsRuntime: vi.fn(() => ({ version: 1, profiles: {} })),
810}));
@@ -16,24 +18,34 @@ const discoveryCoreMocks = vi.hoisted(() => ({
1618scrubLegacyStaticAuthJsonEntriesForDiscovery: vi.fn(),
1719}));
182021+const syntheticAuthMocks = vi.hoisted(() => ({
22+resolveRuntimeSyntheticAuthProviderRefs: vi.fn(() => []),
23+resolveProviderSyntheticAuthWithPlugin: vi.fn(),
24+}));
25+1926vi.mock("./auth-profiles/store.js", () => storeMocks);
20272128vi.mock("./pi-auth-credentials.js", () => credentialMocks);
22292330vi.mock("./pi-auth-discovery-core.js", () => discoveryCoreMocks);
24312532vi.mock("./synthetic-auth.runtime.js", () => ({
26-resolveRuntimeSyntheticAuthProviderRefs: () => [],
33+resolveRuntimeSyntheticAuthProviderRefs:
34+syntheticAuthMocks.resolveRuntimeSyntheticAuthProviderRefs,
2735}));
28362937vi.mock("../plugins/provider-runtime.js", () => ({
30-resolveProviderSyntheticAuthWithPlugin: vi.fn(),
38+resolveProviderSyntheticAuthWithPlugin: syntheticAuthMocks.resolveProviderSyntheticAuthWithPlugin,
3139}));
32403341import { externalCliDiscoveryForProviders } from "./auth-profiles/external-cli-discovery.js";
3442import { resolvePiCredentialsForDiscovery } from "./pi-auth-discovery.js";
35433644describe("resolvePiCredentialsForDiscovery external CLI scoping", () => {
45+beforeEach(() => {
46+vi.clearAllMocks();
47+});
48+3749it("threads scoped external CLI discovery into writable auth store loading", () => {
3850const cfg = {} as OpenClawConfig;
3951const externalCli = externalCliDiscoveryForProviders({
@@ -76,4 +88,29 @@ describe("resolvePiCredentialsForDiscovery external CLI scoping", () => {
7688readOnly: true,
7789});
7890});
91+92+it("can skip runtime external auth overlays and scope synthetic auth discovery", () => {
93+resolvePiCredentialsForDiscovery("/tmp/openclaw-agent", {
94+env: {},
95+skipExternalAuthProfiles: true,
96+syntheticAuthProviderRefs: ["fireworks"],
97+});
98+99+expect(storeMocks.ensureAuthProfileStoreWithoutExternalProfiles).toHaveBeenCalledWith(
100+"/tmp/openclaw-agent",
101+{
102+allowKeychainPrompt: false,
103+},
104+);
105+expect(storeMocks.ensureAuthProfileStore).not.toHaveBeenCalled();
106+expect(syntheticAuthMocks.resolveRuntimeSyntheticAuthProviderRefs).not.toHaveBeenCalled();
107+expect(syntheticAuthMocks.resolveProviderSyntheticAuthWithPlugin).toHaveBeenCalledWith({
108+provider: "fireworks",
109+context: {
110+config: undefined,
111+provider: "fireworks",
112+providerConfig: undefined,
113+},
114+});
115+});
79116});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。