17 lines
899 B
JavaScript
17 lines
899 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { parseTlsTarget } from "../src/tls-probe.js";
|
|
|
|
test("TLS probe target parser accepts hostnames, ports, and HTTPS URLs", () => {
|
|
assert.deepEqual(parseTlsTarget("example.test"), { hostname: "example.test", port: 443 });
|
|
assert.deepEqual(parseTlsTarget("example.test:8443"), { hostname: "example.test", port: 8443 });
|
|
assert.deepEqual(parseTlsTarget("https://example.test:9443"), { hostname: "example.test", port: 9443 });
|
|
});
|
|
|
|
test("TLS probe target parser rejects credentials, paths, and invalid ports", () => {
|
|
assert.throws(() => parseTlsTarget("https://user@example.test"), /hostname and optional port/);
|
|
assert.throws(() => parseTlsTarget("https://example.test/path"), /hostname and optional port/);
|
|
assert.throws(() => parseTlsTarget("example.test:70000"), /Invalid URL|invalid hostname or port/);
|
|
});
|