mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:11:24 +00:00
Onboard: require explicit mode for env secret refs
This commit is contained in:
committed by
Peter Steinberger
parent
103d02f98c
commit
04aa856fc0
@@ -629,6 +629,9 @@ describe("applyAuthChoice", () => {
|
||||
envValue: string;
|
||||
profileId: string;
|
||||
provider: string;
|
||||
opts?: { secretInputMode?: "ref" };
|
||||
expectedKey?: string;
|
||||
expectedKeyRef?: { source: "env"; id: string };
|
||||
expectedModel?: string;
|
||||
expectedModelPrefix?: string;
|
||||
}> = [
|
||||
@@ -638,6 +641,7 @@ describe("applyAuthChoice", () => {
|
||||
envValue: "sk-synthetic-env",
|
||||
profileId: "synthetic:default",
|
||||
provider: "synthetic",
|
||||
expectedKey: "sk-synthetic-env",
|
||||
expectedModelPrefix: "synthetic/",
|
||||
},
|
||||
{
|
||||
@@ -646,6 +650,7 @@ describe("applyAuthChoice", () => {
|
||||
envValue: "sk-openrouter-test",
|
||||
profileId: "openrouter:default",
|
||||
provider: "openrouter",
|
||||
expectedKey: "sk-openrouter-test",
|
||||
expectedModel: "openrouter/auto",
|
||||
},
|
||||
{
|
||||
@@ -654,6 +659,17 @@ describe("applyAuthChoice", () => {
|
||||
envValue: "gateway-test-key",
|
||||
profileId: "vercel-ai-gateway:default",
|
||||
provider: "vercel-ai-gateway",
|
||||
expectedKey: "gateway-test-key",
|
||||
expectedModel: "vercel-ai-gateway/anthropic/claude-opus-4.6",
|
||||
},
|
||||
{
|
||||
authChoice: "ai-gateway-api-key",
|
||||
envKey: "AI_GATEWAY_API_KEY",
|
||||
envValue: "gateway-ref-key",
|
||||
profileId: "vercel-ai-gateway:default",
|
||||
provider: "vercel-ai-gateway",
|
||||
opts: { secretInputMode: "ref" },
|
||||
expectedKeyRef: { source: "env", id: "AI_GATEWAY_API_KEY" },
|
||||
expectedModel: "vercel-ai-gateway/anthropic/claude-opus-4.6",
|
||||
},
|
||||
];
|
||||
@@ -674,6 +690,7 @@ describe("applyAuthChoice", () => {
|
||||
prompter,
|
||||
runtime,
|
||||
setDefaultModel: true,
|
||||
opts: scenario.opts,
|
||||
});
|
||||
|
||||
expect(confirm).toHaveBeenCalledWith(
|
||||
@@ -698,10 +715,14 @@ describe("applyAuthChoice", () => {
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
expect((await readAuthProfile(scenario.profileId))?.keyRef).toEqual({
|
||||
source: "env",
|
||||
id: scenario.envKey,
|
||||
});
|
||||
const profile = await readAuthProfile(scenario.profileId);
|
||||
if (scenario.expectedKeyRef) {
|
||||
expect(profile?.keyRef).toEqual(scenario.expectedKeyRef);
|
||||
expect(profile?.key).toBeUndefined();
|
||||
} else {
|
||||
expect(profile?.key).toBe(scenario.expectedKey);
|
||||
expect(profile?.keyRef).toBeUndefined();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -910,10 +931,7 @@ describe("applyAuthChoice", () => {
|
||||
|
||||
expect(await readAuthProfile("litellm:default")).toMatchObject({
|
||||
type: "api_key",
|
||||
keyRef: {
|
||||
source: "env",
|
||||
id: "LITELLM_API_KEY",
|
||||
},
|
||||
key: "sk-litellm-test",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -923,9 +941,10 @@ describe("applyAuthChoice", () => {
|
||||
textValues: string[];
|
||||
confirmValue: boolean;
|
||||
opts?: {
|
||||
cloudflareAiGatewayAccountId: string;
|
||||
cloudflareAiGatewayGatewayId: string;
|
||||
cloudflareAiGatewayApiKey: string;
|
||||
secretInputMode?: "ref";
|
||||
cloudflareAiGatewayAccountId?: string;
|
||||
cloudflareAiGatewayGatewayId?: string;
|
||||
cloudflareAiGatewayApiKey?: string;
|
||||
};
|
||||
expectEnvPrompt: boolean;
|
||||
expectedKey?: string;
|
||||
@@ -937,13 +956,27 @@ describe("applyAuthChoice", () => {
|
||||
textValues: ["cf-account-id", "cf-gateway-id"],
|
||||
confirmValue: true,
|
||||
expectEnvPrompt: true,
|
||||
expectedKey: "cf-gateway-test-key",
|
||||
expectedMetadata: {
|
||||
accountId: "cf-account-id",
|
||||
gatewayId: "cf-gateway-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
envGatewayKey: "cf-gateway-ref-key",
|
||||
textValues: ["cf-account-id-ref", "cf-gateway-id-ref"],
|
||||
confirmValue: true,
|
||||
opts: {
|
||||
secretInputMode: "ref",
|
||||
},
|
||||
expectEnvPrompt: true,
|
||||
expectedKeyRef: {
|
||||
source: "env",
|
||||
id: "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
||||
},
|
||||
expectedMetadata: {
|
||||
accountId: "cf-account-id",
|
||||
gatewayId: "cf-gateway-id",
|
||||
accountId: "cf-account-id-ref",
|
||||
gatewayId: "cf-gateway-id-ref",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user