Files
OmniRoute/tests/unit/tls-client-proxy-fail-closed.test.ts
Diego Rodrigues de Sa e Souza 76a07cf7a5 Release v3.8.24 (#3747)
Release v3.8.24 — see CHANGELOG.md [3.8.24] for the full notes and the PR description for the contributors hall. Integration of release/v3.8.24 into main.
2026-06-13 17:27:40 -03:00

40 lines
1.2 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { resolveTlsClientProxyUrl } from "../../open-sse/services/tlsClientProxy.ts";
describe("resolveTlsClientProxyUrl — fail-closed", () => {
it("returns the per-call override verbatim", () => {
assert.equal(
resolveTlsClientProxyUrl("https://grok.com", "http://p:8080", () => null),
"http://p:8080"
);
});
it("returns undefined when no proxy is configured (direct is legitimate)", () => {
assert.equal(
resolveTlsClientProxyUrl("https://grok.com", undefined, () => ({
source: "direct",
proxyUrl: null,
})),
undefined
);
});
it("returns the resolved proxy url when one is configured", () => {
assert.equal(
resolveTlsClientProxyUrl("https://grok.com", undefined, () => ({
source: "context",
proxyUrl: "socks5://p:1080",
})),
"socks5://p:1080"
);
});
it("THROWS (fail-closed) when resolution throws — never silently direct", () => {
assert.throws(
() =>
resolveTlsClientProxyUrl("https://grok.com", undefined, () => {
throw new Error("SOCKS5 disabled");
}),
/proxy resolution failed/i
);
});
});