- The egress job runs through WorkerHelper.getEgressRecoveryJob(), like
the cleanup jobs, instead of a direct service call from the queue
- Toggling egressCheckEnabled resets the egress state and removes any
pending recovery job
- Probes resolve and pass the proxy, so http targets honour the global
proxy as monitors do
- PingProvider keeps IPv6 addresses intact instead of truncating at the
first colon
- Egress targets are parsed by one function shared by the validator and
the probe; malformed addresses such as unbalanced brackets are rejected
- Notification id pattern drops the /i flag, which produced an invalid
OpenAPI pattern
- EgressState findSingleton reads before it writes, so a read no longer
bumps updatedAt
- "disabled" is a distinct assessment result and is cached like any other
- Concurrent failures share an in-flight assessment for as long as it
runs, then reuse the settled result for 5 s
- The recovery job row is only removed if nobody rescheduled it since
this run claimed it, so a concurrent new episode keeps its job
- Deleting a notification removes it from egressNotifications
🔧
50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "@jest/globals";
|
|
import { parseEgressTarget } from "../../../src/utils/egressTarget.ts";
|
|
|
|
describe("parseEgressTarget", () => {
|
|
it("parses http(s) URLs", () => {
|
|
expect(parseEgressTarget("https://example.com/health")).toEqual({ kind: "http", url: "https://example.com/health" });
|
|
expect(parseEgressTarget("HTTP://example.com")).toEqual({ kind: "http", url: "HTTP://example.com" });
|
|
expect(parseEgressTarget("http://[2606:4700::1111]:8080/")).toEqual({ kind: "http", url: "http://[2606:4700::1111]:8080/" });
|
|
});
|
|
|
|
it("parses host:port with a hostname, IPv4 address, localhost or bracketed IPv6 address", () => {
|
|
expect(parseEgressTarget("dns.google:53")).toEqual({ kind: "port", host: "dns.google", port: 53 });
|
|
expect(parseEgressTarget("8.8.8.8:53")).toEqual({ kind: "port", host: "8.8.8.8", port: 53 });
|
|
expect(parseEgressTarget("localhost:8080")).toEqual({ kind: "port", host: "localhost", port: 8080 });
|
|
expect(parseEgressTarget("[2606:4700::1111]:443")).toEqual({ kind: "port", host: "2606:4700::1111", port: 443 });
|
|
});
|
|
|
|
it("parses bare hosts and addresses as ping targets", () => {
|
|
expect(parseEgressTarget("1.1.1.1")).toEqual({ kind: "ping", host: "1.1.1.1" });
|
|
expect(parseEgressTarget("example.com")).toEqual({ kind: "ping", host: "example.com" });
|
|
expect(parseEgressTarget("2606:4700:4700::1111")).toEqual({ kind: "ping", host: "2606:4700:4700::1111" });
|
|
expect(parseEgressTarget("[2606:4700:4700::1111]")).toEqual({ kind: "ping", host: "2606:4700:4700::1111" });
|
|
expect(parseEgressTarget(" 1.1.1.1 ")).toEqual({ kind: "ping", host: "1.1.1.1" });
|
|
});
|
|
|
|
it("rejects anything the probe could not reach", () => {
|
|
for (const target of [
|
|
"",
|
|
"ftp://example.com",
|
|
"http://",
|
|
"bad host",
|
|
"1.1.1.1;rm",
|
|
"[1.1.1.1",
|
|
"1.1.1.1]",
|
|
"[::1",
|
|
"::1]",
|
|
"[[::1]]",
|
|
"[not-an-address]:53",
|
|
"[1.1.1.1]:53",
|
|
"999.1.1.1",
|
|
"1.1.1.1:0",
|
|
"1.1.1.1:70000",
|
|
"1.1.1.1:",
|
|
"host-without-tld",
|
|
]) {
|
|
expect(parseEgressTarget(target)).toBeNull();
|
|
}
|
|
});
|
|
});
|