mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 06:11:37 +00:00
* refactor(deadcode): trim auto-reply and CLI exports * refactor(deadcode): trim cron and task exports * refactor(deadcode): trim fleet and process exports * test(deadcode): exercise live task and process seams * test(fleet): cover stream redaction through owner module * refactor(security): trim dead internal exports * refactor(secrets): trim dead internal exports * refactor(deadcode): trim remaining src exports * refactor(deadcode): remove test-only runtime exports * refactor(deadcode): trim pairing test exports * refactor(deadcode): reconcile refreshed baseline * test(auto-reply): deduplicate queue state imports
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
/** Tests command-specific secret assignment collection from config snapshots. */
|
|
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
import {
|
|
buildTalkTestProviderConfig,
|
|
TALK_TEST_PROVIDER_API_KEY_PATH,
|
|
TALK_TEST_PROVIDER_API_KEY_PATH_SEGMENTS,
|
|
} from "../test-utils/talk-test-provider.js";
|
|
import { analyzeCommandSecretAssignmentsFromSnapshot } from "./command-config.js";
|
|
|
|
describe("analyzeCommandSecretAssignmentsFromSnapshot", () => {
|
|
it("returns assignments from the active runtime snapshot for configured refs", () => {
|
|
const sourceConfig = buildTalkTestProviderConfig({
|
|
source: "env",
|
|
provider: "default",
|
|
id: "TALK_API_KEY",
|
|
});
|
|
const resolvedConfig = buildTalkTestProviderConfig("talk-key"); // pragma: allowlist secret
|
|
|
|
const result = analyzeCommandSecretAssignmentsFromSnapshot({
|
|
sourceConfig,
|
|
resolvedConfig,
|
|
targetIds: new Set(["talk.providers.*.apiKey"]),
|
|
});
|
|
|
|
expect(result.assignments).toEqual([
|
|
{
|
|
path: TALK_TEST_PROVIDER_API_KEY_PATH,
|
|
pathSegments: [...TALK_TEST_PROVIDER_API_KEY_PATH_SEGMENTS],
|
|
value: "talk-key",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("reports configured refs that are unresolved in the snapshot", () => {
|
|
const sourceConfig = buildTalkTestProviderConfig({
|
|
source: "env",
|
|
provider: "default",
|
|
id: "TALK_API_KEY",
|
|
});
|
|
const resolvedConfig = buildTalkTestProviderConfig(undefined);
|
|
|
|
const result = analyzeCommandSecretAssignmentsFromSnapshot({
|
|
sourceConfig,
|
|
resolvedConfig,
|
|
targetIds: new Set(["talk.providers.*.apiKey"]),
|
|
});
|
|
|
|
expect(result.unresolved).toEqual([
|
|
{
|
|
path: TALK_TEST_PROVIDER_API_KEY_PATH,
|
|
pathSegments: [...TALK_TEST_PROVIDER_API_KEY_PATH_SEGMENTS],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("skips unresolved refs that are marked inactive by runtime warnings", () => {
|
|
const sourceConfig = {
|
|
agents: {
|
|
defaults: {
|
|
memorySearch: {
|
|
remote: {
|
|
apiKey: { source: "env", provider: "default", id: "DEFAULT_MEMORY_KEY" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as unknown as OpenClawConfig;
|
|
const resolvedConfig = {
|
|
agents: {
|
|
defaults: {
|
|
memorySearch: {
|
|
remote: {
|
|
apiKey: { source: "env", provider: "default", id: "DEFAULT_MEMORY_KEY" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as unknown as OpenClawConfig;
|
|
|
|
const result = analyzeCommandSecretAssignmentsFromSnapshot({
|
|
sourceConfig,
|
|
resolvedConfig,
|
|
targetIds: new Set(["agents.defaults.memorySearch.remote.apiKey"]),
|
|
inactiveRefPaths: new Set(["agents.defaults.memorySearch.remote.apiKey"]),
|
|
});
|
|
|
|
expect(result.assignments).toStrictEqual([]);
|
|
expect(result.diagnostics).toEqual([
|
|
"agents.defaults.memorySearch.remote.apiKey: secret ref is configured on an inactive surface; skipping command-time assignment.",
|
|
]);
|
|
});
|
|
});
|