


























@@ -151,11 +151,13 @@ describe("googlechat monitor webhook", () => {
151151],
152152],
153153]);
154+const webhookInFlightLimiter = {} as never;
155+const processEvent = vi.fn(async () => {});
154156const handler = createGoogleChatWebhookRequestHandler({
155157 webhookTargets,
156158webhookRateLimiter: rateLimiter,
157-webhookInFlightLimiter: {} as never,
158-processEvent: vi.fn(async () => {}),
159+ webhookInFlightLimiter,
160+ processEvent,
159161});
160162const req = createRequest({
161163url: "/googlechat?ignored=1",
@@ -169,12 +171,17 @@ describe("googlechat monitor webhook", () => {
169171170172await expect(handler(req, res)).resolves.toBe(true);
171173172-expect(withResolvedWebhookRequestPipeline).toHaveBeenCalledWith(
173-expect.objectContaining({
174- rateLimiter,
175-rateLimitKey: "/googlechat:198.51.100.7",
176-}),
177-);
174+expect(withResolvedWebhookRequestPipeline).toHaveBeenCalledWith({
175+ req,
176+ res,
177+targetsByPath: webhookTargets,
178+allowMethods: ["POST"],
179+requireJsonContentType: true,
180+ rateLimiter,
181+rateLimitKey: "/googlechat:198.51.100.7",
182+inFlightLimiter: webhookInFlightLimiter,
183+handle: expect.any(Function),
184+});
178185});
179186180187it("uses the unknown rate-limit bucket when a trusted proxy omits client headers", async () => {
@@ -205,24 +212,31 @@ describe("googlechat monitor webhook", () => {
205212],
206213],
207214]);
215+const webhookInFlightLimiter = {} as never;
216+const processEvent = vi.fn(async () => {});
208217const handler = createGoogleChatWebhookRequestHandler({
209218 webhookTargets,
210219webhookRateLimiter: rateLimiter,
211-webhookInFlightLimiter: {} as never,
212-processEvent: vi.fn(async () => {}),
220+ webhookInFlightLimiter,
221+ processEvent,
213222});
214223const req = createRequest({ remoteAddress: "10.0.0.1" });
215224const res = createResponse();
216225withResolvedWebhookRequestPipeline.mockResolvedValue(true);
217226218227await expect(handler(req, res)).resolves.toBe(true);
219228220-expect(withResolvedWebhookRequestPipeline).toHaveBeenCalledWith(
221-expect.objectContaining({
222- rateLimiter,
223-rateLimitKey: "/googlechat:unknown",
224-}),
225-);
229+expect(withResolvedWebhookRequestPipeline).toHaveBeenCalledWith({
230+ req,
231+ res,
232+targetsByPath: webhookTargets,
233+allowMethods: ["POST"],
234+requireJsonContentType: true,
235+ rateLimiter,
236+rateLimitKey: "/googlechat:unknown",
237+inFlightLimiter: webhookInFlightLimiter,
238+handle: expect.any(Function),
239+});
226240});
227241228242it("accepts add-on payloads that carry systemIdToken in the body", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。