fix(secrets): harden plan target paths and ref-only auth profiles

This commit is contained in:
Peter Steinberger
2026-02-26 14:25:01 +01:00
parent 485cd0c512
commit 820d614757
6 changed files with 258 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { upsertAuthProfile } from "./auth-profiles.js";
import { resolveImplicitProviders } from "./models-config.providers.js";
describe("Volcengine and BytePlus providers", () => {
@@ -37,4 +38,40 @@ describe("Volcengine and BytePlus providers", () => {
envSnapshot.restore();
}
});
it("includes providers when auth profiles are env keyRef-only", async () => {
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
const envSnapshot = captureEnv(["VOLCANO_ENGINE_API_KEY", "BYTEPLUS_API_KEY"]);
delete process.env.VOLCANO_ENGINE_API_KEY;
delete process.env.BYTEPLUS_API_KEY;
upsertAuthProfile({
profileId: "volcengine:default",
credential: {
type: "api_key",
provider: "volcengine",
keyRef: { source: "env", provider: "default", id: "VOLCANO_ENGINE_API_KEY" },
},
agentDir,
});
upsertAuthProfile({
profileId: "byteplus:default",
credential: {
type: "api_key",
provider: "byteplus",
keyRef: { source: "env", provider: "default", id: "BYTEPLUS_API_KEY" },
},
agentDir,
});
try {
const providers = await resolveImplicitProviders({ agentDir });
expect(providers?.volcengine?.apiKey).toBe("VOLCANO_ENGINE_API_KEY");
expect(providers?.["volcengine-plan"]?.apiKey).toBe("VOLCANO_ENGINE_API_KEY");
expect(providers?.byteplus?.apiKey).toBe("BYTEPLUS_API_KEY");
expect(providers?.["byteplus-plan"]?.apiKey).toBe("BYTEPLUS_API_KEY");
} finally {
envSnapshot.restore();
}
});
});