import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { describe, expect, it } from "vitest"; import { resolveSlackAccount } from "./accounts.js";
it("throws when an enabled account still has an unresolved active bot token SecretRef", () => {
expect(() =>
resolveSlackAccount({
cfg: cfgWithUnresolvedBotTokenRef,
accountId: "default",
}),
).toThrowError(/channels\.slack\.accounts\.default\.botToken/);
});
it("throws when a socket-mode account still has an unresolved active app token SecretRef", () => {
expect(() =>
resolveSlackAccount({
cfg: {
channels: {
slack: {
accounts: { default: {
mode: "socket",
botToken: "xoxb-resolved",
appToken: secretRef,
},
},
},
},
} as unknown as OpenClawConfig,
accountId: "default",
}),
).toThrowError(/channels\.slack\.accounts\.default\.appToken/);
});
it("preserves env fallback when no active config token is set", () => { const previousBotToken = process.env.SLACK_BOT_TOKEN; const previousAppToken = process.env.SLACK_APP_TOKEN;
process.env.SLACK_BOT_TOKEN = "xoxb-env-only";
process.env.SLACK_APP_TOKEN = "xapp-env-only"; try { // No SecretRef and no string token configured for the default account: // env fallback must still fire so env-only deployments (relying solely // on SLACK_BOT_TOKEN / SLACK_APP_TOKEN) keep working when callers like // `channel.ts` invoke sendMessageSlack without an explicit override. const resolved = resolveSlackAccount({
cfg: {
channels: {
slack: {
accounts: { default: { allowFrom: ["U001"] },
},
},
},
},
accountId: "default",
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.