19 lines
1.2 KiB
TypeScript
19 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import { readFile } from "node:fs/promises"
|
|
import { buildFlowAgentInstaller } from "./traffic-flow-agent-install.js"
|
|
import { buildTrafficFlowHostFiles } from "./traffic-flow-host-file-builders.js"
|
|
const files = buildTrafficFlowHostFiles({ collectorIp: "10.255.254.1", prefix: "10.255.254.0/24", flowListenPort: 4740,
|
|
wgListenPort: 51821, hostPrivateKey: Buffer.alloc(32, 1).toString("base64"), peers: [] })
|
|
const conf = files.find(file => file.id === "wg-quick")!.code
|
|
const source = await readFile(new URL("../../../deploy/netflow-agent/install.sh", import.meta.url), "utf8")
|
|
const script = buildFlowAgentInstaller(conf, 4740, source)
|
|
assert.ok(script.startsWith("#!/usr/bin/env bash\n"))
|
|
assert.ok(script.includes(conf.trim() + "\nMM_CONFIG_EOF\n"))
|
|
assert.ok(script.includes('"${1:-/opt/cdn-mm}" 4740'))
|
|
assert.ok(script.includes("[email protected]"))
|
|
assert.ok(script.includes("docker-compose.netflow-agent.yml"))
|
|
assert.ok(!script.includes("\r"))
|
|
assert.throws(() => buildFlowAgentInstaller("MM_CONFIG_EOF\n", 4739, source))
|
|
assert.throws(() => buildFlowAgentInstaller(conf, 0, source))
|
|
console.log("NetFlow agent installer export: validated snapshot, custom port/path, embedded installer and LF-only output")
|