From 13458025bccb81fd50de3d07d6eb6975ef69296d Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 09:53:18 +0100 Subject: [PATCH] test: tighten discord dm auth assertions --- .../src/monitor/dm-command-auth.test.ts | 102 ++++++++---------- 1 file changed, 45 insertions(+), 57 deletions(-) diff --git a/extensions/discord/src/monitor/dm-command-auth.test.ts b/extensions/discord/src/monitor/dm-command-auth.test.ts index 14f76b4497a0..78e1d9213860 100644 --- a/extensions/discord/src/monitor/dm-command-auth.test.ts +++ b/extensions/discord/src/monitor/dm-command-auth.test.ts @@ -27,76 +27,64 @@ describe("resolveDiscordTextCommandAccess", () => { }; it("authorizes guild text commands from owner allowlists", async () => { - await expect( - resolveDiscordTextCommandAccess({ - accountId: "default", - sender, - ownerAllowFrom: ["discord:123"], - memberAccessConfigured: false, - memberAllowed: false, - allowNameMatching: false, - allowTextCommands: true, - hasControlCommand: true, - }), - ).resolves.toMatchObject({ - authorized: true, - shouldBlockControlCommand: false, + const result = await resolveDiscordTextCommandAccess({ + accountId: "default", + sender, + ownerAllowFrom: ["discord:123"], + memberAccessConfigured: false, + memberAllowed: false, + allowNameMatching: false, + allowTextCommands: true, + hasControlCommand: true, }); + expect(result.authorized).toBe(true); + expect(result.shouldBlockControlCommand).toBe(false); }); it("authorizes guild text commands from member access facts", async () => { - await expect( - resolveDiscordTextCommandAccess({ - accountId: "default", - sender, - ownerAllowFrom: [], - memberAccessConfigured: true, - memberAllowed: true, - allowNameMatching: false, - allowTextCommands: true, - hasControlCommand: true, - }), - ).resolves.toMatchObject({ - authorized: true, - shouldBlockControlCommand: false, + const result = await resolveDiscordTextCommandAccess({ + accountId: "default", + sender, + ownerAllowFrom: [], + memberAccessConfigured: true, + memberAllowed: true, + allowNameMatching: false, + allowTextCommands: true, + hasControlCommand: true, }); + expect(result.authorized).toBe(true); + expect(result.shouldBlockControlCommand).toBe(false); }); it("blocks unauthorized guild text control commands", async () => { - await expect( - resolveDiscordTextCommandAccess({ - accountId: "default", - sender, - ownerAllowFrom: ["discord:999"], - memberAccessConfigured: true, - memberAllowed: false, - allowNameMatching: false, - allowTextCommands: true, - hasControlCommand: true, - }), - ).resolves.toMatchObject({ - authorized: false, - shouldBlockControlCommand: true, + const result = await resolveDiscordTextCommandAccess({ + accountId: "default", + sender, + ownerAllowFrom: ["discord:999"], + memberAccessConfigured: true, + memberAllowed: false, + allowNameMatching: false, + allowTextCommands: true, + hasControlCommand: true, }); + expect(result.authorized).toBe(false); + expect(result.shouldBlockControlCommand).toBe(true); }); it("preserves configured mode when access groups are disabled", async () => { - await expect( - resolveDiscordTextCommandAccess({ - accountId: "default", - sender, - ownerAllowFrom: [], - memberAccessConfigured: false, - memberAllowed: false, - allowNameMatching: false, - cfg: { commands: { useAccessGroups: false } }, - allowTextCommands: true, - hasControlCommand: true, - }), - ).resolves.toMatchObject({ - authorized: true, - shouldBlockControlCommand: false, + const result = await resolveDiscordTextCommandAccess({ + accountId: "default", + sender, + ownerAllowFrom: [], + memberAccessConfigured: false, + memberAllowed: false, + allowNameMatching: false, + cfg: { commands: { useAccessGroups: false } }, + allowTextCommands: true, + hasControlCommand: true, }); + expect(result.authorized).toBe(true); + expect(result.shouldBlockControlCommand).toBe(false); }); });