mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
test: tighten proxy validation assertions
This commit is contained in:
@@ -199,23 +199,19 @@ describe("proxy validation", () => {
|
||||
targetUrl: DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0],
|
||||
timeoutMs: 5000,
|
||||
});
|
||||
const deniedCall = fetchCheck.mock.calls[1]?.[0];
|
||||
expect(deniedCall).toMatchObject({
|
||||
proxyUrl: "http://127.0.0.1:3128",
|
||||
timeoutMs: 5000,
|
||||
});
|
||||
const deniedCall = fetchCheck.mock.calls[1]?.[0] as
|
||||
| { proxyUrl?: unknown; targetUrl?: string; timeoutMs?: unknown }
|
||||
| undefined;
|
||||
expect(deniedCall?.proxyUrl).toBe("http://127.0.0.1:3128");
|
||||
expect(deniedCall?.timeoutMs).toBe(5000);
|
||||
expect(deniedCall?.targetUrl).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.checks[0]).toMatchObject({
|
||||
kind: "allowed",
|
||||
url: DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0],
|
||||
ok: true,
|
||||
});
|
||||
expect(result.checks[1]).toMatchObject({
|
||||
kind: "denied",
|
||||
ok: true,
|
||||
error: "loopback blocked",
|
||||
});
|
||||
expect(result.checks[0]?.kind).toBe("allowed");
|
||||
expect(result.checks[0]?.url).toBe(DEFAULT_PROXY_VALIDATION_ALLOWED_URLS[0]);
|
||||
expect(result.checks[0]?.ok).toBe(true);
|
||||
expect(result.checks[1]?.kind).toBe("denied");
|
||||
expect(result.checks[1]?.ok).toBe(true);
|
||||
expect(result.checks[1]?.error).toBe("loopback blocked");
|
||||
expect(result.checks[1]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
|
||||
});
|
||||
|
||||
@@ -238,12 +234,12 @@ describe("proxy validation", () => {
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.checks).toHaveLength(1);
|
||||
expect(result.checks[0]).toMatchObject({
|
||||
kind: "denied",
|
||||
ok: false,
|
||||
status: 204,
|
||||
error: "Denied loopback canary returned HTTP 204 without the validation token",
|
||||
});
|
||||
expect(result.checks[0]?.kind).toBe("denied");
|
||||
expect(result.checks[0]?.ok).toBe(false);
|
||||
expect(result.checks[0]?.status).toBe(204);
|
||||
expect(result.checks[0]?.error).toBe(
|
||||
"Denied loopback canary returned HTTP 204 without the validation token",
|
||||
);
|
||||
expect(result.checks[0]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
|
||||
});
|
||||
|
||||
@@ -260,11 +256,9 @@ describe("proxy validation", () => {
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.checks).toHaveLength(1);
|
||||
expect(result.checks[0]).toMatchObject({
|
||||
kind: "denied",
|
||||
ok: true,
|
||||
status: 403,
|
||||
});
|
||||
expect(result.checks[0]?.kind).toBe("denied");
|
||||
expect(result.checks[0]?.ok).toBe(true);
|
||||
expect(result.checks[0]?.status).toBe(403);
|
||||
expect(result.checks[0]?.url).toMatch(/^http:\/\/127\.0\.0\.1:\d+\/$/);
|
||||
});
|
||||
|
||||
@@ -505,14 +499,11 @@ describe("proxy validation", () => {
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.checks).toEqual([
|
||||
{
|
||||
kind: "apns",
|
||||
url: "https://api.sandbox.push.apple.com",
|
||||
ok: false,
|
||||
error: expect.stringContaining("InvalidProviderToken"),
|
||||
},
|
||||
]);
|
||||
expect(result.checks).toHaveLength(1);
|
||||
expect(result.checks[0]?.kind).toBe("apns");
|
||||
expect(result.checks[0]?.url).toBe("https://api.sandbox.push.apple.com");
|
||||
expect(result.checks[0]?.ok).toBe(false);
|
||||
expect(result.checks[0]?.error).toContain("InvalidProviderToken");
|
||||
});
|
||||
|
||||
it("fails APNs reachability when non-403 response has no apns-id (proxy intercept)", async () => {
|
||||
@@ -529,14 +520,11 @@ describe("proxy validation", () => {
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.checks).toEqual([
|
||||
{
|
||||
kind: "apns",
|
||||
url: "https://api.sandbox.push.apple.com",
|
||||
ok: false,
|
||||
error: expect.stringContaining("apns-id"),
|
||||
},
|
||||
]);
|
||||
expect(result.checks).toHaveLength(1);
|
||||
expect(result.checks[0]?.kind).toBe("apns");
|
||||
expect(result.checks[0]?.url).toBe("https://api.sandbox.push.apple.com");
|
||||
expect(result.checks[0]?.ok).toBe(false);
|
||||
expect(result.checks[0]?.error).toContain("apns-id");
|
||||
});
|
||||
|
||||
it("fails APNs reachability when the proxy blocks CONNECT", async () => {
|
||||
|
||||
Reference in New Issue
Block a user