Onboarding: honor generic token for GigaChat OAuth
This commit is contained in:
parent
8fdece2b52
commit
16043ad618
@ -74,4 +74,47 @@ describe("applySimpleNonInteractiveApiKeyChoice", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts the generic --token input for GigaChat non-interactive OAuth", async () => {
|
||||
const nextConfig = { agents: { defaults: {} } } as OpenClawConfig;
|
||||
const resolveApiKey = vi.fn(async () => ({
|
||||
key: "gigachat-token-credentials",
|
||||
source: "flag" as const,
|
||||
}));
|
||||
const maybeSetResolvedApiKey = vi.fn(async (resolved, setter) => {
|
||||
await setter(resolved.key);
|
||||
return true;
|
||||
});
|
||||
|
||||
await applySimpleNonInteractiveApiKeyChoice({
|
||||
authChoice: "gigachat-oauth",
|
||||
nextConfig,
|
||||
baseConfig: nextConfig,
|
||||
opts: { token: "gigachat-token-credentials" } as never,
|
||||
runtime: { error: vi.fn(), exit: vi.fn(), log: vi.fn() } as never,
|
||||
apiKeyStorageOptions: undefined,
|
||||
resolveApiKey,
|
||||
maybeSetResolvedApiKey,
|
||||
});
|
||||
|
||||
expect(resolveApiKey).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
provider: "gigachat",
|
||||
flagValue: "gigachat-token-credentials",
|
||||
flagName: "--gigachat-api-key",
|
||||
envVar: "GIGACHAT_CREDENTIALS",
|
||||
allowProfile: false,
|
||||
}),
|
||||
);
|
||||
expect(setGigachatApiKey).toHaveBeenCalledWith(
|
||||
"gigachat-token-credentials",
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
authMode: "oauth",
|
||||
insecureTls: "false",
|
||||
scope: "GIGACHAT_API_PERS",
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -39,7 +39,7 @@ async function applyGigachatNonInteractiveApiKeyChoice(params: {
|
||||
const resolved = await params.resolveApiKey({
|
||||
provider: "gigachat",
|
||||
cfg: params.baseConfig,
|
||||
flagValue: params.opts.gigachatApiKey,
|
||||
flagValue: params.opts.gigachatApiKey ?? params.opts.token,
|
||||
flagName: "--gigachat-api-key",
|
||||
envVar: "GIGACHAT_CREDENTIALS",
|
||||
runtime: params.runtime,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user