mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 05:31:30 +00:00
* secrets: harden read-only SecretRef resolution for status and audit * CLI: add SecretRef degrade-safe regression coverage * Docs: align SecretRef status and daemon probe semantics * Security audit: close SecretRef review gaps * Security audit: preserve source auth SecretRef configuredness * changelog Signed-off-by: joshavant <830519+joshavant@users.noreply.github.com> --------- Signed-off-by: joshavant <830519+joshavant@users.noreply.github.com>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
|
|
const pluginRegistry = vi.hoisted(() => ({ list: [] as unknown[] }));
|
|
|
|
vi.mock("../channels/plugins/index.js", () => ({
|
|
listChannelPlugins: () => pluginRegistry.list,
|
|
}));
|
|
|
|
import { resolveLinkChannelContext } from "./status.link-channel.js";
|
|
|
|
describe("resolveLinkChannelContext", () => {
|
|
it("returns linked context from read-only inspected account state", async () => {
|
|
const account = { configured: true, enabled: true };
|
|
pluginRegistry.list = [
|
|
{
|
|
id: "discord",
|
|
meta: { label: "Discord" },
|
|
config: {
|
|
listAccountIds: () => ["default"],
|
|
inspectAccount: () => account,
|
|
resolveAccount: () => {
|
|
throw new Error("should not be called in read-only mode");
|
|
},
|
|
},
|
|
status: {
|
|
buildChannelSummary: () => ({ linked: true, authAgeMs: 1234 }),
|
|
},
|
|
},
|
|
];
|
|
|
|
const result = await resolveLinkChannelContext({} as OpenClawConfig);
|
|
expect(result?.linked).toBe(true);
|
|
expect(result?.authAgeMs).toBe(1234);
|
|
expect(result?.account).toBe(account);
|
|
});
|
|
|
|
it("degrades safely when account resolution throws", async () => {
|
|
pluginRegistry.list = [
|
|
{
|
|
id: "discord",
|
|
meta: { label: "Discord" },
|
|
config: {
|
|
listAccountIds: () => ["default"],
|
|
resolveAccount: () => {
|
|
throw new Error("missing secret");
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const result = await resolveLinkChannelContext({} as OpenClawConfig);
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|