From 506b4decbd86a70a3cfccb4da3e68e27d08f6ae4 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 6 Apr 2026 16:52:47 +0100 Subject: [PATCH] test(secrets): mock bundled channel secrets seam --- .../runtime-channel-inactive-variants.test.ts | 28 +++++++++++++++---- src/secrets/runtime-discord-surface.test.ts | 6 ++++ ...runtime-inactive-telegram-surfaces.test.ts | 6 ++++ src/secrets/runtime-legacy-x-search.test.ts | 6 ++++ src/secrets/runtime-matrix-shadowing.test.ts | 6 ++++ src/secrets/runtime-matrix-top-level.test.ts | 6 ++++ ...ime-nextcloud-talk-file-precedence.test.ts | 6 ++++ ...runtime-telegram-token-inheritance.test.ts | 6 ++++ .../runtime-zalo-token-activity.test.ts | 6 ++++ 9 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/secrets/runtime-channel-inactive-variants.test.ts b/src/secrets/runtime-channel-inactive-variants.test.ts index f5024900ab5..ba082939613 100644 --- a/src/secrets/runtime-channel-inactive-variants.test.ts +++ b/src/secrets/runtime-channel-inactive-variants.test.ts @@ -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; + }, }; }); diff --git a/src/secrets/runtime-discord-surface.test.ts b/src/secrets/runtime-discord-surface.test.ts index 8a218d84c14..9464ae375a4 100644 --- a/src/secrets/runtime-discord-surface.test.ts +++ b/src/secrets/runtime-discord-surface.test.ts @@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "discord" + ? { + collectRuntimeConfigAssignments: discordSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-inactive-telegram-surfaces.test.ts b/src/secrets/runtime-inactive-telegram-surfaces.test.ts index acac50416a6..32c28e20a6f 100644 --- a/src/secrets/runtime-inactive-telegram-surfaces.test.ts +++ b/src/secrets/runtime-inactive-telegram-surfaces.test.ts @@ -14,6 +14,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "telegram" + ? { + collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-legacy-x-search.test.ts b/src/secrets/runtime-legacy-x-search.test.ts index 280a8a03849..fdda52e91fe 100644 --- a/src/secrets/runtime-legacy-x-search.test.ts +++ b/src/secrets/runtime-legacy-x-search.test.ts @@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "telegram" + ? { + collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-matrix-shadowing.test.ts b/src/secrets/runtime-matrix-shadowing.test.ts index b8e26deaab3..89bada8ef58 100644 --- a/src/secrets/runtime-matrix-shadowing.test.ts +++ b/src/secrets/runtime-matrix-shadowing.test.ts @@ -26,6 +26,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "matrix" + ? { + collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-matrix-top-level.test.ts b/src/secrets/runtime-matrix-top-level.test.ts index 82de298c316..c534b58da73 100644 --- a/src/secrets/runtime-matrix-top-level.test.ts +++ b/src/secrets/runtime-matrix-top-level.test.ts @@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "matrix" + ? { + collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-nextcloud-talk-file-precedence.test.ts b/src/secrets/runtime-nextcloud-talk-file-precedence.test.ts index 325d6b6c4c1..969091e1e38 100644 --- a/src/secrets/runtime-nextcloud-talk-file-precedence.test.ts +++ b/src/secrets/runtime-nextcloud-talk-file-precedence.test.ts @@ -16,6 +16,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "nextcloud-talk" + ? { + collectRuntimeConfigAssignments: nextcloudTalkSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-telegram-token-inheritance.test.ts b/src/secrets/runtime-telegram-token-inheritance.test.ts index de2ac584832..65ff623aeb5 100644 --- a/src/secrets/runtime-telegram-token-inheritance.test.ts +++ b/src/secrets/runtime-telegram-token-inheritance.test.ts @@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "telegram" + ? { + collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; }); diff --git a/src/secrets/runtime-zalo-token-activity.test.ts b/src/secrets/runtime-zalo-token-activity.test.ts index cc72f38a28d..0517f724190 100644 --- a/src/secrets/runtime-zalo-token-activity.test.ts +++ b/src/secrets/runtime-zalo-token-activity.test.ts @@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => { }, } : undefined, + getBootstrapChannelSecrets: (id: string) => + id === "zalo" + ? { + collectRuntimeConfigAssignments: zaloSecrets.collectRuntimeConfigAssignments, + } + : undefined, }; });