mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-04 22:41:41 +00:00
test(messages): lock external alias authorization order
This commit is contained in:
@@ -890,6 +890,70 @@ describe("runMessageAction plugin dispatch", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects directory-only external aliases before resolver or plugin code", async () => {
|
||||
const looksLikeId = vi.fn(() => false);
|
||||
const resolveTarget = vi.fn(async () => ({
|
||||
to: "actionhub:current",
|
||||
kind: "group" as const,
|
||||
}));
|
||||
const listGroups = vi.fn(async () => [
|
||||
{ kind: "group" as const, id: "actionhub:current", name: "current-room" },
|
||||
]);
|
||||
const listGroupsLive = vi.fn(async () => [
|
||||
{ kind: "group" as const, id: "actionhub:current", name: "current-room" },
|
||||
]);
|
||||
setActivePluginRegistry(
|
||||
createTestRegistry([
|
||||
{
|
||||
pluginId: "actionhub",
|
||||
source: "test",
|
||||
origin: "config",
|
||||
plugin: {
|
||||
...actionHubPlugin,
|
||||
messaging: {
|
||||
...actionHubPlugin.messaging,
|
||||
targetResolver: { looksLikeId, resolveTarget },
|
||||
},
|
||||
directory: { listGroups, listGroupsLive },
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
await expect(
|
||||
runMessageAction({
|
||||
cfg: {
|
||||
channels: {
|
||||
actionhub: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
action: "pin",
|
||||
params: {
|
||||
channel: "actionhub",
|
||||
target: "current-room",
|
||||
messageId: "om_123",
|
||||
},
|
||||
defaultAccountId: "default",
|
||||
requesterAccountId: "default",
|
||||
conversationReadOrigin: "delegated",
|
||||
toolContext: {
|
||||
currentChannelId: "actionhub:current",
|
||||
currentChannelProvider: "actionhub",
|
||||
currentChatType: "group",
|
||||
},
|
||||
dryRun: false,
|
||||
}),
|
||||
).rejects.toThrow("requires the exact current conversation and account");
|
||||
|
||||
expect(looksLikeId).not.toHaveBeenCalled();
|
||||
expect(resolveTarget).not.toHaveBeenCalled();
|
||||
expect(listGroups).not.toHaveBeenCalled();
|
||||
expect(listGroupsLive).not.toHaveBeenCalled();
|
||||
expect(handleAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves no-context owner Discord admin actions through the shared runner", async () => {
|
||||
const handleDiscordAction = vi.fn(async (ctx: ChannelMessageActionContext) => {
|
||||
const currentProvider = ctx.toolContext?.currentChannelProvider?.trim().toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user