Files
openclaw-zero-token/secrets/command-config.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

92 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { collectCommandSecretAssignmentsFromSnapshot } from "./command-config.js";
describe("collectCommandSecretAssignmentsFromSnapshot", () => {
it("returns assignments from the active runtime snapshot for configured refs", () => {
const sourceConfig = {
talk: {
apiKey: { source: "env", provider: "default", id: "TALK_API_KEY" },
},
} as unknown as OpenClawConfig;
const resolvedConfig = {
talk: {
apiKey: "talk-key", // pragma: allowlist secret
},
} as unknown as OpenClawConfig;
const result = collectCommandSecretAssignmentsFromSnapshot({
sourceConfig,
resolvedConfig,
commandName: "memory status",
targetIds: new Set(["talk.apiKey"]),
});
expect(result.assignments).toEqual([
{
path: "talk.apiKey",
pathSegments: ["talk", "apiKey"],
value: "talk-key",
},
]);
});
it("throws when configured refs are unresolved in the snapshot", () => {
const sourceConfig = {
talk: {
apiKey: { source: "env", provider: "default", id: "TALK_API_KEY" },
},
} as unknown as OpenClawConfig;
const resolvedConfig = {
talk: {},
} as unknown as OpenClawConfig;
expect(() =>
collectCommandSecretAssignmentsFromSnapshot({
sourceConfig,
resolvedConfig,
commandName: "memory search",
targetIds: new Set(["talk.apiKey"]),
}),
).toThrow(/memory search: talk\.apiKey is unresolved in the active runtime snapshot/);
});
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 = collectCommandSecretAssignmentsFromSnapshot({
sourceConfig,
resolvedConfig,
commandName: "memory search",
targetIds: new Set(["agents.defaults.memorySearch.remote.apiKey"]),
inactiveRefPaths: new Set(["agents.defaults.memorySearch.remote.apiKey"]),
});
expect(result.assignments).toEqual([]);
expect(result.diagnostics).toEqual([
"agents.defaults.memorySearch.remote.apiKey: secret ref is configured on an inactive surface; skipping command-time assignment.",
]);
});
});