mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test(secrets): mock bundled channel secrets seam
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "discord"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: discordSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "telegram"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "telegram"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -26,6 +26,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "matrix"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "matrix"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: matrixSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "nextcloud-talk"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: nextcloudTalkSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "telegram"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: telegramSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ vi.mock("../channels/plugins/bootstrap-registry.js", async () => {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
getBootstrapChannelSecrets: (id: string) =>
|
||||
id === "zalo"
|
||||
? {
|
||||
collectRuntimeConfigAssignments: zaloSecrets.collectRuntimeConfigAssignments,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user