feat: unify group policy allowlists
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
allowListMatches,
|
||||
type DiscordGuildEntryResolved,
|
||||
isDiscordGroupAllowedByPolicy,
|
||||
normalizeDiscordAllowList,
|
||||
normalizeDiscordSlug,
|
||||
resolveDiscordChannelConfig,
|
||||
@@ -132,6 +133,58 @@ describe("discord guild/channel resolution", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("discord groupPolicy gating", () => {
|
||||
it("allows when policy is open", () => {
|
||||
expect(
|
||||
isDiscordGroupAllowedByPolicy({
|
||||
groupPolicy: "open",
|
||||
channelAllowlistConfigured: false,
|
||||
channelAllowed: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("blocks when policy is disabled", () => {
|
||||
expect(
|
||||
isDiscordGroupAllowedByPolicy({
|
||||
groupPolicy: "disabled",
|
||||
channelAllowlistConfigured: true,
|
||||
channelAllowed: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks allowlist when no channel allowlist configured", () => {
|
||||
expect(
|
||||
isDiscordGroupAllowedByPolicy({
|
||||
groupPolicy: "allowlist",
|
||||
channelAllowlistConfigured: false,
|
||||
channelAllowed: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("allows allowlist when channel is allowed", () => {
|
||||
expect(
|
||||
isDiscordGroupAllowedByPolicy({
|
||||
groupPolicy: "allowlist",
|
||||
channelAllowlistConfigured: true,
|
||||
channelAllowed: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("blocks allowlist when channel is not allowed", () => {
|
||||
expect(
|
||||
isDiscordGroupAllowedByPolicy({
|
||||
groupPolicy: "allowlist",
|
||||
channelAllowlistConfigured: true,
|
||||
channelAllowed: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("discord group DM gating", () => {
|
||||
it("allows all when no allowlist", () => {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user