mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:12:44 +00:00
refactor(test): dedupe cloudflare onboarding provider auth cases
This commit is contained in:
@@ -446,76 +446,60 @@ describe("onboard (non-interactive): provider auth", () => {
|
|||||||
});
|
});
|
||||||
}, 60_000);
|
}, 60_000);
|
||||||
|
|
||||||
it("stores Cloudflare AI Gateway API key and metadata", async () => {
|
it.each([
|
||||||
await withOnboardEnv("openclaw-onboard-cf-gateway-", async ({ configPath, runtime }) => {
|
{
|
||||||
await runNonInteractive(
|
name: "stores Cloudflare AI Gateway API key and metadata",
|
||||||
{
|
prefix: "openclaw-onboard-cf-gateway-",
|
||||||
nonInteractive: true,
|
options: {
|
||||||
authChoice: "cloudflare-ai-gateway-api-key",
|
authChoice: "cloudflare-ai-gateway-api-key",
|
||||||
cloudflareAiGatewayAccountId: "cf-account-id",
|
},
|
||||||
cloudflareAiGatewayGatewayId: "cf-gateway-id",
|
},
|
||||||
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
|
{
|
||||||
skipHealth: true,
|
name: "infers Cloudflare auth choice from API key flags",
|
||||||
skipChannels: true,
|
prefix: "openclaw-onboard-cf-gateway-infer-",
|
||||||
skipSkills: true,
|
options: {},
|
||||||
json: true,
|
},
|
||||||
},
|
])(
|
||||||
runtime,
|
"$name",
|
||||||
);
|
async ({ prefix, options }) => {
|
||||||
|
await withOnboardEnv(prefix, async ({ configPath, runtime }) => {
|
||||||
|
await runNonInteractive(
|
||||||
|
{
|
||||||
|
nonInteractive: true,
|
||||||
|
cloudflareAiGatewayAccountId: "cf-account-id",
|
||||||
|
cloudflareAiGatewayGatewayId: "cf-gateway-id",
|
||||||
|
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
|
||||||
|
skipHealth: true,
|
||||||
|
skipChannels: true,
|
||||||
|
skipSkills: true,
|
||||||
|
json: true,
|
||||||
|
...options,
|
||||||
|
},
|
||||||
|
runtime,
|
||||||
|
);
|
||||||
|
|
||||||
const cfg = await readJsonFile<{
|
const cfg = await readJsonFile<{
|
||||||
auth?: { profiles?: Record<string, { provider?: string; mode?: string }> };
|
auth?: { profiles?: Record<string, { provider?: string; mode?: string }> };
|
||||||
agents?: { defaults?: { model?: { primary?: string } } };
|
agents?: { defaults?: { model?: { primary?: string } } };
|
||||||
}>(configPath);
|
}>(configPath);
|
||||||
|
|
||||||
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe(
|
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe(
|
||||||
"cloudflare-ai-gateway",
|
"cloudflare-ai-gateway",
|
||||||
);
|
);
|
||||||
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key");
|
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key");
|
||||||
expect(cfg.agents?.defaults?.model?.primary).toBe("cloudflare-ai-gateway/claude-sonnet-4-5");
|
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||||
await expectApiKeyProfile({
|
"cloudflare-ai-gateway/claude-sonnet-4-5",
|
||||||
profileId: "cloudflare-ai-gateway:default",
|
);
|
||||||
provider: "cloudflare-ai-gateway",
|
await expectApiKeyProfile({
|
||||||
key: "cf-gateway-test-key",
|
profileId: "cloudflare-ai-gateway:default",
|
||||||
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
|
provider: "cloudflare-ai-gateway",
|
||||||
|
key: "cf-gateway-test-key",
|
||||||
|
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
}, 60_000);
|
60_000,
|
||||||
|
);
|
||||||
it("infers Cloudflare auth choice from API key flags", async () => {
|
|
||||||
await withOnboardEnv("openclaw-onboard-cf-gateway-infer-", async ({ configPath, runtime }) => {
|
|
||||||
await runNonInteractive(
|
|
||||||
{
|
|
||||||
nonInteractive: true,
|
|
||||||
cloudflareAiGatewayAccountId: "cf-account-id",
|
|
||||||
cloudflareAiGatewayGatewayId: "cf-gateway-id",
|
|
||||||
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
|
|
||||||
skipHealth: true,
|
|
||||||
skipChannels: true,
|
|
||||||
skipSkills: true,
|
|
||||||
json: true,
|
|
||||||
},
|
|
||||||
runtime,
|
|
||||||
);
|
|
||||||
|
|
||||||
const cfg = await readJsonFile<{
|
|
||||||
auth?: { profiles?: Record<string, { provider?: string; mode?: string }> };
|
|
||||||
agents?: { defaults?: { model?: { primary?: string } } };
|
|
||||||
}>(configPath);
|
|
||||||
|
|
||||||
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe(
|
|
||||||
"cloudflare-ai-gateway",
|
|
||||||
);
|
|
||||||
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key");
|
|
||||||
expect(cfg.agents?.defaults?.model?.primary).toBe("cloudflare-ai-gateway/claude-sonnet-4-5");
|
|
||||||
await expectApiKeyProfile({
|
|
||||||
profileId: "cloudflare-ai-gateway:default",
|
|
||||||
provider: "cloudflare-ai-gateway",
|
|
||||||
key: "cf-gateway-test-key",
|
|
||||||
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 60_000);
|
|
||||||
|
|
||||||
it("infers Together auth choice from --together-api-key and sets default model", async () => {
|
it("infers Together auth choice from --together-api-key and sets default model", async () => {
|
||||||
await withOnboardEnv("openclaw-onboard-together-infer-", async ({ configPath, runtime }) => {
|
await withOnboardEnv("openclaw-onboard-together-infer-", async ({ configPath, runtime }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user