mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
1769fb2aa1
* Config: add inspect/strict SecretRef string resolver * CLI: pass resolved/source config snapshots to plugin preload * Slack: keep HTTP route registration config-only * Providers: normalize SecretRef handling for auth and web tools * Secrets: add Exa web search target to registry and docs * Telegram: resolve env SecretRef tokens at runtime * Agents: resolve custom provider env SecretRef ids * Providers: fail closed on blocked SecretRef fallback * Telegram: enforce env SecretRef policy for runtime token refs * Status/Providers/Telegram: tighten SecretRef preload and fallback handling * Providers: enforce env SecretRef policy checks in fallback auth paths * fix: add SecretRef lifecycle changelog entry (#66818) (thanks @joshavant)
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { normalizeResolvedSecretInputString, resolveSecretInputString } from "./types.secrets.js";
|
|
|
|
describe("resolveSecretInputString", () => {
|
|
it("returns available for non-empty string values", () => {
|
|
expect(
|
|
resolveSecretInputString({
|
|
value: " abc123 ",
|
|
path: "models.providers.openai.apiKey",
|
|
}),
|
|
).toEqual({
|
|
status: "available",
|
|
value: "abc123",
|
|
ref: null,
|
|
});
|
|
});
|
|
|
|
it("returns configured_unavailable for unresolved refs in inspect mode", () => {
|
|
expect(
|
|
resolveSecretInputString({
|
|
value: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
path: "models.providers.openai.apiKey",
|
|
mode: "inspect",
|
|
}),
|
|
).toEqual({
|
|
status: "configured_unavailable",
|
|
value: undefined,
|
|
ref: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
});
|
|
});
|
|
|
|
it("uses explicit refValue in inspect mode", () => {
|
|
expect(
|
|
resolveSecretInputString({
|
|
value: "",
|
|
refValue: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
path: "profiles.default.key",
|
|
mode: "inspect",
|
|
}),
|
|
).toEqual({
|
|
status: "configured_unavailable",
|
|
value: undefined,
|
|
ref: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
});
|
|
});
|
|
|
|
it("returns missing when no value or ref is configured", () => {
|
|
expect(
|
|
resolveSecretInputString({
|
|
value: "",
|
|
path: "models.providers.openai.apiKey",
|
|
mode: "inspect",
|
|
}),
|
|
).toEqual({
|
|
status: "missing",
|
|
value: undefined,
|
|
ref: null,
|
|
});
|
|
});
|
|
|
|
it("throws for unresolved refs in strict mode", () => {
|
|
expect(() =>
|
|
resolveSecretInputString({
|
|
value: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
path: "models.providers.openai.apiKey",
|
|
}),
|
|
).toThrow(/unresolved SecretRef/);
|
|
});
|
|
});
|
|
|
|
describe("normalizeResolvedSecretInputString", () => {
|
|
it("keeps strict unresolved-ref behavior", () => {
|
|
expect(() =>
|
|
normalizeResolvedSecretInputString({
|
|
value: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
path: "models.providers.openai.apiKey",
|
|
}),
|
|
).toThrow(/unresolved SecretRef/);
|
|
});
|
|
});
|