





















@@ -1,5 +1,6 @@
11import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
22import { describe, expect, it } from "vitest";
3+import { MSTeamsConfigSchema } from "../config-api.js";
34import { msTeamsApprovalAuth } from "./approval-auth.js";
45import { msteamsPlugin } from "./channel.js";
56@@ -46,3 +47,82 @@ describe("msteamsPlugin", () => {
4647expect(looksLikeId?.("user:Jane Doe")).toBe(false);
4748});
4849});
50+51+describe("msteams config schema", () => {
52+it("defaults groupPolicy to allowlist", () => {
53+const res = MSTeamsConfigSchema.safeParse({});
54+55+expect(res.success).toBe(true);
56+if (res.success) {
57+expect(res.data.groupPolicy).toBe("allowlist");
58+}
59+});
60+61+it("accepts historyLimit", () => {
62+const res = MSTeamsConfigSchema.safeParse({ historyLimit: 4 });
63+64+expect(res.success).toBe(true);
65+if (res.success) {
66+expect(res.data.historyLimit).toBe(4);
67+}
68+});
69+70+it("accepts replyStyle at global/team/channel levels", () => {
71+const res = MSTeamsConfigSchema.safeParse({
72+replyStyle: "top-level",
73+teams: {
74+team123: {
75+replyStyle: "thread",
76+channels: {
77+chan456: { replyStyle: "top-level" },
78+},
79+},
80+},
81+});
82+83+expect(res.success).toBe(true);
84+if (res.success) {
85+expect(res.data.replyStyle).toBe("top-level");
86+expect(res.data.teams?.team123?.replyStyle).toBe("thread");
87+expect(res.data.teams?.team123?.channels?.chan456?.replyStyle).toBe("top-level");
88+}
89+});
90+91+it("rejects invalid replyStyle", () => {
92+const res = MSTeamsConfigSchema.safeParse({
93+replyStyle: "nope",
94+});
95+96+expect(res.success).toBe(false);
97+});
98+});
99+100+describe("msTeamsApprovalAuth", () => {
101+it("authorizes stable Teams user ids and ignores display-name allowlists", () => {
102+expect(
103+msTeamsApprovalAuth.authorizeActorAction({
104+cfg: {
105+channels: {
106+msteams: {
107+allowFrom: ["user:123e4567-e89b-12d3-a456-426614174000"],
108+},
109+},
110+},
111+senderId: "123e4567-e89b-12d3-a456-426614174000",
112+action: "approve",
113+approvalKind: "exec",
114+}),
115+).toEqual({ authorized: true });
116+117+expect(
118+msTeamsApprovalAuth.authorizeActorAction({
119+cfg: {
120+channels: { msteams: { allowFrom: ["Owner Display"] } },
121+},
122+senderId: "attacker-aad",
123+action: "approve",
124+approvalKind: "exec",
125+}),
126+).toEqual({ authorized: true });
127+});
128+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。