From 09c7cb5d3408aabd3dc6068ff265d626f8c406d0 Mon Sep 17 00:00:00 2001 From: joshavant <830519+joshavant@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:32:06 -0600 Subject: [PATCH] Tests: update onboard credential expectations for explicit ref mode --- src/commands/onboard-auth.credentials.test.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/commands/onboard-auth.credentials.test.ts b/src/commands/onboard-auth.credentials.test.ts index a7a14642a..902a44bf5 100644 --- a/src/commands/onboard-auth.credentials.test.ts +++ b/src/commands/onboard-auth.credentials.test.ts @@ -19,13 +19,29 @@ describe("onboard auth credentials secret refs", () => { await lifecycle.cleanup(); }); - it("stores env-backed moonshot key as keyRef", async () => { + it("keeps env-backed moonshot key as plaintext by default", async () => { const env = await setupAuthTestEnv("openclaw-onboard-auth-credentials-"); lifecycle.setStateDir(env.stateDir); process.env.MOONSHOT_API_KEY = "sk-moonshot-env"; await setMoonshotApiKey("sk-moonshot-env"); + const parsed = await readAuthProfilesForAgent<{ + profiles?: Record; + }>(env.agentDir); + expect(parsed.profiles?.["moonshot:default"]).toMatchObject({ + key: "sk-moonshot-env", + }); + expect(parsed.profiles?.["moonshot:default"]?.keyRef).toBeUndefined(); + }); + + it("stores env-backed moonshot key as keyRef in ref mode", async () => { + const env = await setupAuthTestEnv("openclaw-onboard-auth-credentials-ref-"); + lifecycle.setStateDir(env.stateDir); + process.env.MOONSHOT_API_KEY = "sk-moonshot-env"; + + await setMoonshotApiKey("sk-moonshot-env", env.agentDir, { secretInputMode: "ref" }); + const parsed = await readAuthProfilesForAgent<{ profiles?: Record; }>(env.agentDir); @@ -71,7 +87,9 @@ describe("onboard auth credentials secret refs", () => { lifecycle.setStateDir(env.stateDir); process.env.CLOUDFLARE_AI_GATEWAY_API_KEY = "cf-secret"; - await setCloudflareAiGatewayConfig("account-1", "gateway-1", "cf-secret"); + await setCloudflareAiGatewayConfig("account-1", "gateway-1", "cf-secret", env.agentDir, { + secretInputMode: "ref", + }); const parsed = await readAuthProfilesForAgent<{ profiles?: Record;