






















@@ -199,23 +199,19 @@ describe("proxy validation", () => {
199199targetUrl: DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0],
200200timeoutMs: 5000,
201201});
202-const deniedCall = fetchCheck.mock.calls[1]?.[0];
203-expect(deniedCall).toMatchObject({
204-proxyUrl: "http://127.0.0.1:3128",
205- timeoutMs: 5000,
206-});
202+const deniedCall = fetchCheck.mock.calls[1]?.[0] as
203+ | { proxyUrl?: unknown; targetUrl?: string; timeoutMs?: unknown }
204+| undefined;
205+expect(deniedCall?.proxyUrl).toBe("http://127.0.0.1:3128");
206+expect(deniedCall?.timeoutMs).toBe(5000);
207207expect(deniedCall?.targetUrl).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
208208expect(result.ok).toBe(true);
209-expect(result.checks[0]).toMatchObject({
210-kind: "allowed",
211-url: DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0],
212-ok: true,
213-});
214-expect(result.checks[1]).toMatchObject({
215-kind: "denied",
216-ok: true,
217-error: "loopback blocked",
218-});
209+expect(result.checks[0]?.kind).toBe("allowed");
210+expect(result.checks[0]?.url).toBe(DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0]);
211+expect(result.checks[0]?.ok).toBe(true);
212+expect(result.checks[1]?.kind).toBe("denied");
213+expect(result.checks[1]?.ok).toBe(true);
214+expect(result.checks[1]?.error).toBe("loopback blocked");
219215expect(result.checks[1]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
220216});
221217@@ -238,12 +234,12 @@ describe("proxy validation", () => {
238234239235expect(result.ok).toBe(false);
240236expect(result.checks).toHaveLength(1);
241-expect(result.checks[0]).toMatchObject({
242- kind: "denied",
243- ok: false,
244- status: 204,
245-error: "Denied loopback canary returned HTTP 204 without the validation token",
246-});
237+expect(result.checks[0]?.kind).toBe("denied");
238+expect(result.checks[0]?.ok).toBe(false);
239+expect(result.checks[0]?.status).toBe(204);
240+expect(result.checks[0]?.error).toBe(
241+"Denied loopback canary returned HTTP 204 without the validation token",
242+);
247243expect(result.checks[0]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
248244});
249245@@ -260,11 +256,9 @@ describe("proxy validation", () => {
260256261257expect(result.ok).toBe(true);
262258expect(result.checks).toHaveLength(1);
263-expect(result.checks[0]).toMatchObject({
264-kind: "denied",
265-ok: true,
266-status: 403,
267-});
259+expect(result.checks[0]?.kind).toBe("denied");
260+expect(result.checks[0]?.ok).toBe(true);
261+expect(result.checks[0]?.status).toBe(403);
268262expect(result.checks[0]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
269263});
270264@@ -505,14 +499,11 @@ describe("proxy validation", () => {
505499});
506500507501expect(result.ok).toBe(false);
508-expect(result.checks).toEqual([
509-{
510-kind: "apns",
511-url: "https://api.sandbox.push.apple.com",
512-ok: false,
513-error: expect.stringContaining("InvalidProviderToken"),
514-},
515-]);
502+expect(result.checks).toHaveLength(1);
503+expect(result.checks[0]?.kind).toBe("apns");
504+expect(result.checks[0]?.url).toBe("https://api.sandbox.push.apple.com");
505+expect(result.checks[0]?.ok).toBe(false);
506+expect(result.checks[0]?.error).toContain("InvalidProviderToken");
516507});
517508518509it("fails APNs reachability when non-403 response has no apns-id (proxy intercept)", async () => {
@@ -529,14 +520,11 @@ describe("proxy validation", () => {
529520});
530521531522expect(result.ok).toBe(false);
532-expect(result.checks).toEqual([
533-{
534-kind: "apns",
535-url: "https://api.sandbox.push.apple.com",
536-ok: false,
537-error: expect.stringContaining("apns-id"),
538-},
539-]);
523+expect(result.checks).toHaveLength(1);
524+expect(result.checks[0]?.kind).toBe("apns");
525+expect(result.checks[0]?.url).toBe("https://api.sandbox.push.apple.com");
526+expect(result.checks[0]?.ok).toBe(false);
527+expect(result.checks[0]?.error).toContain("apns-id");
540528});
541529542530it("fails APNs reachability when the proxy blocks CONNECT", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。