* Tests: stabilize detect-secrets fixtures * Tests: fix rebased detect-secrets false positives * Docs: keep snippets valid under detect-secrets * Tests: finalize detect-secrets false-positive fixes * Tests: reduce detect-secrets false positives * Tests: keep detect-secrets pragmas inline * Tests: remediate next detect-secrets batch * Tests: tighten detect-secrets allowlists * Tests: stabilize detect-secrets formatter drift
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
import { resolveOnboardingSecretInputString } from "./onboarding.secret-input.js";
|
|
|
|
function makeConfig(): OpenClawConfig {
|
|
return {
|
|
secrets: {
|
|
providers: {
|
|
default: { source: "env" },
|
|
},
|
|
},
|
|
} as OpenClawConfig;
|
|
}
|
|
|
|
describe("resolveOnboardingSecretInputString", () => {
|
|
it("resolves env-template SecretInput strings", async () => {
|
|
const resolved = await resolveOnboardingSecretInputString({
|
|
config: makeConfig(),
|
|
value: "${OPENCLAW_GATEWAY_PASSWORD}",
|
|
path: "gateway.auth.password",
|
|
env: {
|
|
OPENCLAW_GATEWAY_PASSWORD: "gateway-secret", // pragma: allowlist secret
|
|
},
|
|
});
|
|
|
|
expect(resolved).toBe("gateway-secret");
|
|
});
|
|
|
|
it("returns plaintext strings when value is not a SecretRef", async () => {
|
|
const resolved = await resolveOnboardingSecretInputString({
|
|
config: makeConfig(),
|
|
value: "plain-text",
|
|
path: "gateway.auth.password",
|
|
});
|
|
|
|
expect(resolved).toBe("plain-text");
|
|
});
|
|
|
|
it("throws with path context when env-template SecretRef cannot resolve", async () => {
|
|
await expect(
|
|
resolveOnboardingSecretInputString({
|
|
config: makeConfig(),
|
|
value: "${OPENCLAW_GATEWAY_PASSWORD}",
|
|
path: "gateway.auth.password",
|
|
env: {},
|
|
}),
|
|
).rejects.toThrow(
|
|
'gateway.auth.password: failed to resolve SecretRef "env:default:OPENCLAW_GATEWAY_PASSWORD"',
|
|
);
|
|
});
|
|
});
|