

























@@ -73,6 +73,15 @@ const policy: ChannelIngressPolicyInput = {
7373groupPolicy: "allowlist",
7474};
757576+function expectRecordFields(record: unknown, expected: Record<string, unknown>) {
77+expect(record).toBeDefined();
78+const actual = record as Record<string, unknown>;
79+for (const [key, value] of Object.entries(expected)) {
80+expect(actual[key]).toEqual(value);
81+}
82+return actual;
83+}
84+7685describe("channel message access ingress", () => {
7786it.each([
7887{
@@ -114,8 +123,8 @@ describe("channel message access ingress", () => {
114123},
115124])("$name", async ({ input, policy, expected, secondPolicy, secondExpected }) => {
116125const state = await resolveChannelIngressState(input);
117-expect(decideChannelIngress(state, policy)).toMatchObject(expected);
118-expect(decideChannelIngress(state, secondPolicy)).toMatchObject(secondExpected);
126+expectRecordFields(decideChannelIngress(state, policy), expected);
127+expectRecordFields(decideChannelIngress(state, secondPolicy), secondExpected);
119128});
120129121130it("applies route sender allowlists without retaining raw sender values", async () => {
@@ -141,11 +150,11 @@ describe("channel message access ingress", () => {
141150142151const decision = decideChannelIngress(state, policy);
143152144-expect(state.routeFacts[0]?.senderAllowlist).toMatchObject({
153+const senderAllowlist = expectRecordFields(state.routeFacts[0]?.senderAllowlist, {
145154hasConfiguredEntries: true,
146-match: { matched: true },
147155});
148-expect(decision).toMatchObject({ admission: "dispatch", decision: "allow" });
156+expectRecordFields(senderAllowlist.match, { matched: true });
157+expectRecordFields(decision, { admission: "dispatch", decision: "allow" });
149158expect(JSON.stringify(state)).not.toContain(rawSender);
150159expect(JSON.stringify(decision)).not.toContain(rawSender);
151160});
@@ -168,7 +177,7 @@ describe("channel message access ingress", () => {
168177}),
169178);
170179171-expect(decideChannelIngress(state, policy)).toMatchObject({
180+expectRecordFields(decideChannelIngress(state, policy), {
172181admission: "drop",
173182reasonCode: "route_sender_empty",
174183});
@@ -216,11 +225,12 @@ describe("channel message access ingress", () => {
216225const decision = decideChannelIngress(state, policy);
217226218227expect(state.event.originSubjectMatched).toBe(entry.matched);
219-expect(decision).toMatchObject(entry.expected);
228+expectRecordFields(decision, entry.expected);
220229if (entry.matched) {
221-expect(
222-decision.graph.gates.find((gate) => gate.phase === "sender" && gate.kind === "dmSender"),
223-).toMatchObject({
230+const gate = decision.graph.gates.find(
231+(gate) => gate.phase === "sender" && gate.kind === "dmSender",
232+);
233+expectRecordFields(gate, {
224234effect: "ignore",
225235reasonCode: "sender_not_required",
226236});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。