mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-21 15:01:03 +00:00
* refactor: move Telegram channel implementation to extensions/telegram/src/ Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin files) from src/telegram/ and src/channels/plugins/*/telegram.ts to extensions/telegram/src/. Leave thin re-export shims at original locations so cross-cutting src/ imports continue to resolve. - Fix all relative import paths in moved files (../X/ -> ../../../src/X/) - Fix vi.mock paths in 60 test files - Fix inline typeof import() expressions - Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS - Update write-plugin-sdk-entry-dts.ts for new rootDir structure - Move channel plugin files with correct path remapping * fix: support keyed telegram send deps * fix: sync telegram extension copies with latest main * fix: correct import paths and remove misplaced files in telegram extension * fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { NormalizedAllowFrom } from "./bot-access.js";
|
|
import { evaluateTelegramGroupBaseAccess } from "./group-access.js";
|
|
|
|
function allow(entries: string[], hasWildcard = false): NormalizedAllowFrom {
|
|
return {
|
|
entries,
|
|
hasWildcard,
|
|
hasEntries: entries.length > 0 || hasWildcard,
|
|
invalidEntries: [],
|
|
};
|
|
}
|
|
|
|
describe("evaluateTelegramGroupBaseAccess", () => {
|
|
it("fails closed when explicit group allowFrom override is empty", () => {
|
|
const result = evaluateTelegramGroupBaseAccess({
|
|
isGroup: true,
|
|
hasGroupAllowOverride: true,
|
|
effectiveGroupAllow: allow([]),
|
|
senderId: "12345",
|
|
senderUsername: "tester",
|
|
enforceAllowOverride: true,
|
|
requireSenderForAllowOverride: true,
|
|
});
|
|
|
|
expect(result).toEqual({ allowed: false, reason: "group-override-unauthorized" });
|
|
});
|
|
|
|
it("allows group message when override is not configured", () => {
|
|
const result = evaluateTelegramGroupBaseAccess({
|
|
isGroup: true,
|
|
hasGroupAllowOverride: false,
|
|
effectiveGroupAllow: allow([]),
|
|
senderId: "12345",
|
|
senderUsername: "tester",
|
|
enforceAllowOverride: true,
|
|
requireSenderForAllowOverride: true,
|
|
});
|
|
|
|
expect(result).toEqual({ allowed: true });
|
|
});
|
|
|
|
it("allows sender explicitly listed in override", () => {
|
|
const result = evaluateTelegramGroupBaseAccess({
|
|
isGroup: true,
|
|
hasGroupAllowOverride: true,
|
|
effectiveGroupAllow: allow(["12345"]),
|
|
senderId: "12345",
|
|
senderUsername: "tester",
|
|
enforceAllowOverride: true,
|
|
requireSenderForAllowOverride: true,
|
|
});
|
|
|
|
expect(result).toEqual({ allowed: true });
|
|
});
|
|
});
|