mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Integrated into release/v3.8.8. Applied review fixes: moved the SELECT 1 into a pingDb() db helper (no raw SQL in route, Hard Rule #5) + the 503 catch no longer leaks err.message (Hard Rule #12). Thanks @herjarsa!
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { configureUpstreamCa } from "../../src/mitm/upstreamTrust.ts";
|
|
|
|
test("configureUpstreamCa — no-op when pemPath is undefined", () => {
|
|
assert.doesNotThrow(() => configureUpstreamCa(undefined));
|
|
});
|
|
|
|
test("configureUpstreamCa — no-op when pemPath is empty string", () => {
|
|
assert.doesNotThrow(() => configureUpstreamCa(""));
|
|
});
|
|
|
|
test("configureUpstreamCa — throws structured error for non-existent path", () => {
|
|
const fakePath = "/nonexistent/path/that/does/not/exist/ca.pem";
|
|
try {
|
|
configureUpstreamCa(fakePath);
|
|
assert.fail("Should have thrown");
|
|
} catch (err) {
|
|
assert.ok(err instanceof Error);
|
|
assert.ok(!err.message.includes(" at /"), `Error message should not contain stack trace: ${err.message}`);
|
|
assert.ok(err.message.includes(fakePath));
|
|
}
|
|
});
|
|
|
|
test("configureUpstreamCa — error message contains AGENTBRIDGE_UPSTREAM_CA_CERT label", () => {
|
|
const fakePath = "/no/such/file.pem";
|
|
try {
|
|
configureUpstreamCa(fakePath);
|
|
assert.fail("Should have thrown");
|
|
} catch (err) {
|
|
assert.ok(err instanceof Error);
|
|
assert.ok(err.message.includes("AGENTBRIDGE_UPSTREAM_CA_CERT"));
|
|
}
|
|
});
|
|
|
|
test("configureUpstreamCa — error does not embed multiline stack trace in message", () => {
|
|
try {
|
|
configureUpstreamCa("/definitely/does/not/exist.pem");
|
|
} catch (err) {
|
|
assert.ok(err instanceof Error);
|
|
assert.ok(!err.message.includes("\n at "));
|
|
}
|
|
});
|