mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:04:33 +00:00
fix(secrets): harden plan target paths and ref-only auth profiles
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user