test(secrets): mock bundled channel secrets seam

This commit is contained in:
Vincent Koc
2026-04-06 16:52:47 +01:00
parent 9c82974082
commit 506b4decbd
9 changed files with 70 additions and 6 deletions

View File

@@ -1,15 +1,13 @@
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import * as googleChatSecrets from "../../extensions/googlechat/src/secret-contract.ts";
import * as ircSecrets from "../../extensions/irc/src/secret-contract.ts";
import * as slackSecrets from "../../extensions/slack/src/secret-contract.ts";
import type { AuthProfileStore } from "../agents/auth-profiles.js";
import type { OpenClawConfig } from "../config/config.js";
import { createEmptyPluginRegistry } from "../plugins/registry.js";
import { setActivePluginRegistry } from "../plugins/runtime.js";
vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
const [ircSecrets, slackSecrets, googleChatSecrets] = await Promise.all([
import("../../extensions/irc/src/secret-contract.ts"),
import("../../extensions/slack/src/secret-contract.ts"),
import("../../extensions/googlechat/src/secret-contract.ts"),
]);
vi.mock("../channels/plugins/bootstrap-registry.js", () => {
return {
getBootstrapChannelPlugin: (id: string) => {
if (id === "irc") {
@@ -35,6 +33,24 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
}
return undefined;
},
getBootstrapChannelSecrets: (id: string) => {
if (id === "irc") {
return {
collectRuntimeConfigAssignments: ircSecrets.collectRuntimeConfigAssignments,
};
}
if (id === "slack") {
return {
collectRuntimeConfigAssignments: slackSecrets.collectRuntimeConfigAssignments,
};
}
if (id === "googlechat") {
return {
collectRuntimeConfigAssignments: googleChatSecrets.collectRuntimeConfigAssignments,
};
}
return undefined;
},
};
});

View File

@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "discord"
? {
collectRuntimeConfigAssignments: discordSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -14,6 +14,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "telegram"
? {
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "telegram"
? {
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -26,6 +26,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "matrix"
? {
collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "matrix"
? {
collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -16,6 +16,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "nextcloud-talk"
? {
collectRuntimeConfigAssignments: nextcloudTalkSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "telegram"
? {
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});

View File

@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
},
}
: undefined,
getBootstrapChannelSecrets: (id: string) =>
id === "zalo"
? {
collectRuntimeConfigAssignments: zaloSecrets.collectRuntimeConfigAssignments,
}
: undefined,
};
});