mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-24 00:11:31 +00:00
Move all Signal channel implementation files from src/signal/ to extensions/signal/src/ and replace originals with re-export shims. This continues the channel plugin migration pattern used by other extensions, keeping backward compatibility via shims while the real code lives in the extension. - Copy 32 .ts files (source + tests) to extensions/signal/src/ - Transform all relative import paths for the new location - Create 2-line re-export shims in src/signal/ for each moved file - Preserve existing extension files (channel.ts, runtime.ts, etc.) - Change tsconfig.plugin-sdk.dts.json rootDir from "src" to "." to support cross-boundary re-exports from extensions/
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isSignalGroupAllowed } from "./identity.js";
|
|
|
|
describe("signal groupPolicy gating", () => {
|
|
it("allows when policy is open", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "open",
|
|
allowFrom: [],
|
|
sender: { kind: "phone", raw: "+15550001111", e164: "+15550001111" },
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("blocks when policy is disabled", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "disabled",
|
|
allowFrom: ["+15550001111"],
|
|
sender: { kind: "phone", raw: "+15550001111", e164: "+15550001111" },
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("blocks allowlist when empty", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "allowlist",
|
|
allowFrom: [],
|
|
sender: { kind: "phone", raw: "+15550001111", e164: "+15550001111" },
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("allows allowlist when sender matches", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "allowlist",
|
|
allowFrom: ["+15550001111"],
|
|
sender: { kind: "phone", raw: "+15550001111", e164: "+15550001111" },
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("allows allowlist wildcard", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "allowlist",
|
|
allowFrom: ["*"],
|
|
sender: { kind: "phone", raw: "+15550002222", e164: "+15550002222" },
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("allows allowlist when uuid sender matches", () => {
|
|
expect(
|
|
isSignalGroupAllowed({
|
|
groupPolicy: "allowlist",
|
|
allowFrom: ["uuid:123e4567-e89b-12d3-a456-426614174000"],
|
|
sender: {
|
|
kind: "uuid",
|
|
raw: "123e4567-e89b-12d3-a456-426614174000",
|
|
},
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
});
|