refactor: unify extension allowlist resolver and directory scaffolding

This commit is contained in:
Peter Steinberger
2026-03-07 22:13:54 +00:00
parent 8e0e76697a
commit 7230b96cc7
10 changed files with 398 additions and 223 deletions

View File

@@ -0,0 +1,40 @@
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
import { describe, expect, it, vi } from "vitest";
vi.mock("./accounts.js", () => ({
resolveFeishuAccount: vi.fn(() => ({
configured: false,
config: {
allowFrom: ["user:alice", "user:bob"],
dms: {
"user:carla": {},
},
groups: {
"chat-1": {},
},
groupAllowFrom: ["chat-2"],
},
})),
}));
import { listFeishuDirectoryGroups, listFeishuDirectoryPeers } from "./directory.js";
describe("feishu directory (config-backed)", () => {
const cfg = {} as ClawdbotConfig;
it("merges allowFrom + dms into peer entries", async () => {
const peers = await listFeishuDirectoryPeers({ cfg, query: "a" });
expect(peers).toEqual([
{ kind: "user", id: "alice" },
{ kind: "user", id: "carla" },
]);
});
it("merges groups map + groupAllowFrom into group entries", async () => {
const groups = await listFeishuDirectoryGroups({ cfg });
expect(groups).toEqual([
{ kind: "group", id: "chat-1" },
{ kind: "group", id: "chat-2" },
]);
});
});