mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-29 16:54:30 +00:00
Auth choice tests: expect env-backed key refs
This commit is contained in:
committed by
Peter Steinberger
parent
56f73ae080
commit
103d02f98c
@@ -46,6 +46,7 @@ vi.mock("./zai-endpoint-detect.js", () => ({
|
||||
|
||||
type StoredAuthProfile = {
|
||||
key?: string;
|
||||
keyRef?: { source: string; id: string };
|
||||
access?: string;
|
||||
refresh?: string;
|
||||
provider?: string;
|
||||
@@ -697,7 +698,10 @@ describe("applyAuthChoice", () => {
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
expect((await readAuthProfile(scenario.profileId))?.key).toBe(scenario.envValue);
|
||||
expect((await readAuthProfile(scenario.profileId))?.keyRef).toEqual({
|
||||
source: "env",
|
||||
id: scenario.envKey,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -906,7 +910,10 @@ describe("applyAuthChoice", () => {
|
||||
|
||||
expect(await readAuthProfile("litellm:default")).toMatchObject({
|
||||
type: "api_key",
|
||||
key: "sk-litellm-test",
|
||||
keyRef: {
|
||||
source: "env",
|
||||
id: "LITELLM_API_KEY",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -921,7 +928,8 @@ describe("applyAuthChoice", () => {
|
||||
cloudflareAiGatewayApiKey: string;
|
||||
};
|
||||
expectEnvPrompt: boolean;
|
||||
expectedKey: string;
|
||||
expectedKey?: string;
|
||||
expectedKeyRef?: { source: string; id: string };
|
||||
expectedMetadata: { accountId: string; gatewayId: string };
|
||||
}> = [
|
||||
{
|
||||
@@ -929,7 +937,10 @@ describe("applyAuthChoice", () => {
|
||||
textValues: ["cf-account-id", "cf-gateway-id"],
|
||||
confirmValue: true,
|
||||
expectEnvPrompt: true,
|
||||
expectedKey: "cf-gateway-test-key",
|
||||
expectedKeyRef: {
|
||||
source: "env",
|
||||
id: "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
||||
},
|
||||
expectedMetadata: {
|
||||
accountId: "cf-account-id",
|
||||
gatewayId: "cf-gateway-id",
|
||||
@@ -993,7 +1004,11 @@ describe("applyAuthChoice", () => {
|
||||
);
|
||||
|
||||
const profile = await readAuthProfile("cloudflare-ai-gateway:default");
|
||||
expect(profile?.key).toBe(scenario.expectedKey);
|
||||
if (scenario.expectedKeyRef) {
|
||||
expect(profile?.keyRef).toEqual(scenario.expectedKeyRef);
|
||||
} else {
|
||||
expect(profile?.key).toBe(scenario.expectedKey);
|
||||
}
|
||||
expect(profile?.metadata).toEqual(scenario.expectedMetadata);
|
||||
}
|
||||
delete process.env.CLOUDFLARE_AI_GATEWAY_API_KEY;
|
||||
|
||||
Reference in New Issue
Block a user