mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-30 22:12:32 +08:00
test: align channel fixtures with open dm policy
This commit is contained in:
@@ -408,11 +408,11 @@ describe("BlueBubbles webhook monitor", () => {
|
||||
expect(sendMessageBlueBubbles).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("allows all DMs when dmPolicy=open", async () => {
|
||||
it("allows wildcard DMs when dmPolicy=open", async () => {
|
||||
setupWebhookTarget({
|
||||
account: createMockAccount({
|
||||
dmPolicy: "open",
|
||||
allowFrom: [],
|
||||
allowFrom: ["*"],
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -483,6 +483,7 @@ describe("BlueBubbles webhook monitor", () => {
|
||||
account: createMockAccount({
|
||||
groupPolicy: "allowlist",
|
||||
dmPolicy: "open",
|
||||
allowFrom: [],
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1876,7 +1877,7 @@ describe("BlueBubbles webhook monitor", () => {
|
||||
expect(mockDispatchReplyWithBufferedBlockDispatcher).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not auto-authorize DM control commands in open mode without allowlists", async () => {
|
||||
it("drops DM control commands in open mode without allowlists", async () => {
|
||||
mockHasControlCommand.mockReturnValue(true);
|
||||
|
||||
setupWebhookTarget({
|
||||
@@ -1894,12 +1895,7 @@ describe("BlueBubbles webhook monitor", () => {
|
||||
|
||||
await dispatchWebhookPayload(payload);
|
||||
|
||||
expect(mockDispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalled();
|
||||
const latestDispatch =
|
||||
mockDispatchReplyWithBufferedBlockDispatcher.mock.calls[
|
||||
mockDispatchReplyWithBufferedBlockDispatcher.mock.calls.length - 1
|
||||
]?.[0];
|
||||
expect(latestDispatch?.ctx?.CommandAuthorized).toBe(false);
|
||||
expect(mockDispatchReplyWithBufferedBlockDispatcher).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export function createMockAccount(
|
||||
password: "test-password",
|
||||
dmPolicy: "open",
|
||||
groupPolicy: "open",
|
||||
allowFrom: [],
|
||||
allowFrom: ["*"],
|
||||
groupAllowFrom: [],
|
||||
...overrides,
|
||||
},
|
||||
|
||||
@@ -1008,7 +1008,7 @@ function makeReactionListenerParams(overrides?: {
|
||||
groupDmEnabled: overrides?.groupDmEnabled ?? true,
|
||||
groupDmChannels: overrides?.groupDmChannels ?? [],
|
||||
dmPolicy: overrides?.dmPolicy ?? "open",
|
||||
allowFrom: overrides?.allowFrom ?? [],
|
||||
allowFrom: overrides?.allowFrom ?? ["*"],
|
||||
groupPolicy: overrides?.groupPolicy ?? "open",
|
||||
allowNameMatching: overrides?.allowNameMatching ?? false,
|
||||
guildEntries: overrides?.guildEntries,
|
||||
|
||||
@@ -200,6 +200,7 @@ describe("Discord ACP bind here end-to-end flow", () => {
|
||||
client: createDmClient("dm-1"),
|
||||
botUserId: "bot-1",
|
||||
}),
|
||||
allowFrom: ["*"],
|
||||
});
|
||||
|
||||
expect(preflight).not.toBeNull();
|
||||
|
||||
@@ -35,7 +35,7 @@ function createConfig(): OpenClawConfig {
|
||||
return {
|
||||
channels: {
|
||||
discord: {
|
||||
dm: { enabled: true, policy: "open" },
|
||||
dm: { enabled: true, policy: "open", allowFrom: ["*"] },
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
@@ -80,7 +80,7 @@ function createConfiguredAcpCase(params: {
|
||||
? {
|
||||
channels: {
|
||||
discord: {
|
||||
dm: { enabled: true, policy: "open" },
|
||||
dm: { enabled: true, policy: "open", allowFrom: ["*"] },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ function createConfig(params?: { requireMention?: boolean }): OpenClawConfig {
|
||||
},
|
||||
channels: {
|
||||
discord: {
|
||||
dm: { enabled: true, policy: "open" },
|
||||
dm: { enabled: true, policy: "open", allowFrom: ["*"] },
|
||||
guilds: {
|
||||
guild1: {
|
||||
requireMention: true,
|
||||
|
||||
@@ -41,9 +41,11 @@ const lifecycleConfig = createFeishuLifecycleConfig({
|
||||
appSecret: "secret_test",
|
||||
channelConfig: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
accountConfig: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -53,6 +55,7 @@ const lifecycleAccount = createResolvedFeishuLifecycleAccount({
|
||||
appSecret: "secret_test",
|
||||
config: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -43,9 +43,11 @@ const lifecycleConfig = createFeishuLifecycleConfig({
|
||||
appSecret: "secret_test",
|
||||
channelConfig: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
accountConfig: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -55,6 +57,7 @@ const lifecycleAccount = createResolvedFeishuLifecycleAccount({
|
||||
appSecret: "secret_test",
|
||||
config: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["ou_user1"],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ function createParams(
|
||||
cfg,
|
||||
accountId: "default",
|
||||
opts: undefined,
|
||||
allowFrom: [],
|
||||
groupAllowFrom: [],
|
||||
groupPolicy: "open",
|
||||
dmPolicy: "open",
|
||||
@@ -55,6 +54,7 @@ function createParams(
|
||||
selfChatCache: undefined,
|
||||
logVerbose: undefined,
|
||||
...restOverrides,
|
||||
allowFrom: restOverrides.allowFrom ?? ["*"],
|
||||
message,
|
||||
messageText,
|
||||
bodyText,
|
||||
|
||||
@@ -168,7 +168,7 @@ describe("signal createSignalEventHandler inbound context", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not auto-authorize DM commands in open mode without allowlists", async () => {
|
||||
it("drops DM commands in open mode without allowlists", async () => {
|
||||
const handler = createSignalEventHandler(
|
||||
createBaseSignalEventHandlerDeps({
|
||||
cfg: {
|
||||
@@ -193,8 +193,8 @@ describe("signal createSignalEventHandler inbound context", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(capture.ctx).toBeTruthy();
|
||||
expect(capture.ctx?.CommandAuthorized).toBe(false);
|
||||
expect(capture.ctx).toBeUndefined();
|
||||
expect(dispatchInboundMessageMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("drops quote-only group context from non-allowlisted quoted senders in allowlist mode", async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { finalizeTelegramInboundContextForTest } from "./bot-message-context.ses
|
||||
|
||||
export const baseTelegramMessageContextConfig = {
|
||||
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
|
||||
channels: { telegram: {} },
|
||||
channels: { telegram: { dmPolicy: "open", allowFrom: ["*"] } },
|
||||
messages: { groupChat: { mentionPatterns: [] } },
|
||||
} as never;
|
||||
|
||||
@@ -80,7 +80,7 @@ export async function buildTelegramMessageContextForTest(
|
||||
historyLimit: 0,
|
||||
groupHistories: new Map(),
|
||||
dmPolicy: "open",
|
||||
allowFrom: [],
|
||||
allowFrom: ["*"],
|
||||
groupAllowFrom: [],
|
||||
ackReactionScope: "off",
|
||||
logger: { info: vi.fn() },
|
||||
|
||||
@@ -21,6 +21,8 @@ function createAccount(): ResolvedZalouserAccount {
|
||||
profile: "default",
|
||||
authenticated: true,
|
||||
config: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["*"],
|
||||
groupPolicy: "open",
|
||||
groups: {
|
||||
"*": { requireMention: true },
|
||||
@@ -34,6 +36,8 @@ function createConfig(): OpenClawConfig {
|
||||
channels: {
|
||||
zalouser: {
|
||||
enabled: true,
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["*"],
|
||||
groups: {
|
||||
"*": { requireMention: true },
|
||||
},
|
||||
@@ -619,7 +623,7 @@ describe("zalouser monitor group mention gating", () => {
|
||||
expect(callArg?.ctx?.SessionKey).toBe("agent:main:zalouser:group:321");
|
||||
});
|
||||
|
||||
it("reads pairing store for open DM control commands", async () => {
|
||||
it("skips pairing store read for open DM control commands", async () => {
|
||||
const { readAllowFromStore } = installRuntime({
|
||||
commandAuthorized: false,
|
||||
});
|
||||
@@ -637,7 +641,7 @@ describe("zalouser monitor group mention gating", () => {
|
||||
runtime: createRuntimeEnv(),
|
||||
});
|
||||
|
||||
expect(readAllowFromStore).toHaveBeenCalledTimes(1);
|
||||
expect(readAllowFromStore).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips pairing store read for open DM non-command messages", async () => {
|
||||
|
||||
Reference in New Issue
Block a user