* Models: gate custom provider keys by usable secret semantics * Config: project runtime writes onto source snapshot * Models: prevent stale apiKey preservation for marker-managed providers * Runner: strip SecretRef marker headers from resolved models * Secrets: scan active agent models.json path in audit * Config: guard runtime-source projection for unrelated configs * Extensions: fix onboarding type errors in CI * Tests: align setup helper account-enabled expectation * Secrets audit: harden models.json file reads * fix: harden SecretRef custom/provider secret persistence (#42554) (thanks @joshavant)
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
|
import { applySetupAccountConfigPatch } from "./setup-helpers.js";
|
|
|
|
function asConfig(value: unknown): OpenClawConfig {
|
|
return value as OpenClawConfig;
|
|
}
|
|
|
|
describe("applySetupAccountConfigPatch", () => {
|
|
it("patches top-level config for default account and enables channel", () => {
|
|
const next = applySetupAccountConfigPatch({
|
|
cfg: asConfig({
|
|
channels: {
|
|
zalo: {
|
|
webhookPath: "/old",
|
|
enabled: false,
|
|
},
|
|
},
|
|
}),
|
|
channelKey: "zalo",
|
|
accountId: DEFAULT_ACCOUNT_ID,
|
|
patch: { webhookPath: "/new", botToken: "tok" },
|
|
});
|
|
|
|
expect(next.channels?.zalo).toMatchObject({
|
|
enabled: true,
|
|
webhookPath: "/new",
|
|
botToken: "tok",
|
|
});
|
|
});
|
|
|
|
it("patches named account config and preserves existing account enabled flag", () => {
|
|
const next = applySetupAccountConfigPatch({
|
|
cfg: asConfig({
|
|
channels: {
|
|
zalo: {
|
|
enabled: false,
|
|
accounts: {
|
|
work: { botToken: "old", enabled: false },
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
channelKey: "zalo",
|
|
accountId: "work",
|
|
patch: { botToken: "new" },
|
|
});
|
|
|
|
expect(next.channels?.zalo).toMatchObject({
|
|
enabled: true,
|
|
accounts: {
|
|
work: { enabled: false, botToken: "new" },
|
|
},
|
|
});
|
|
});
|
|
|
|
it("normalizes account id and preserves other accounts", () => {
|
|
const next = applySetupAccountConfigPatch({
|
|
cfg: asConfig({
|
|
channels: {
|
|
zalo: {
|
|
accounts: {
|
|
personal: { botToken: "personal-token" },
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
channelKey: "zalo",
|
|
accountId: "Work Team",
|
|
patch: { botToken: "work-token" },
|
|
});
|
|
|
|
expect(next.channels?.zalo).toMatchObject({
|
|
accounts: {
|
|
personal: { botToken: "personal-token" },
|
|
"work-team": { enabled: true, botToken: "work-token" },
|
|
},
|
|
});
|
|
});
|
|
});
|