Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Failing after 4m0s
Docker images / backend-image (push) Skipped
Docker images / frontend-image (push) Successful in 3m55s
Docker images / updater-image (push) Successful in 2m11s
Docker images / netflow-agent-image (push) Successful in 37s
Docker images / publish-release (push) Skipped
Docker images / notify-webhook (push) Skipped
43 lines
2.4 KiB
TypeScript
43 lines
2.4 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import { readFileSync } from "node:fs"
|
|
import { test } from "node:test"
|
|
import { ixBondBundleSchema, type IxSite } from "@mmapp/contracts/internet-exchange"
|
|
import { ixGreClientTemplate, ixWireguardClientTemplate } from "./internet-exchange-client.js"
|
|
|
|
const bundle = ixBondBundleSchema.parse(JSON.parse(readFileSync(
|
|
new URL("../../../packages/contracts/testdata/ix-bond-v1.json", import.meta.url), "utf8")))
|
|
|
|
test("the shared ix-client fixture accepts weighted members and rejects overlapping tunnel addresses", () => {
|
|
assert.deepEqual(bundle.members.map(path => path.weight), [3, 1])
|
|
const changed = structuredClone(bundle)
|
|
changed.members[0].probe = changed.members[1].address
|
|
assert.equal(ixBondBundleSchema.safeParse(changed).success, false)
|
|
const invalidKey = structuredClone(bundle)
|
|
invalidKey.members[0].peerPublicKey = "B".repeat(43) + "="
|
|
assert.equal(ixBondBundleSchema.safeParse(invalidKey).success, false)
|
|
})
|
|
|
|
test("group transport brings up an encrypted link without claiming routes used by other members", () => {
|
|
const [wg, gre] = bundle.members
|
|
const linux = { name: bundle.name, enabled: true, exit: "wan", destinations: [], peerEndpoint: "192.0.2.99" }
|
|
const binding: IxSite["interfaces"][number] = {
|
|
name: "wg-test", kind: "wireguard", linux, prefixes: [], provisionWireguard: {
|
|
listenPort: 51820, endpointPort: 51820, localAddress: wg.probe + "/30", peerAddress: wg.address,
|
|
hubEndpoint: wg.endpoint, peerPublicKey: wg.peerPublicKey!,
|
|
},
|
|
}
|
|
const wgConfig = ixWireguardClientTemplate(binding, wg.peerPublicKey!, bundle.destinations, undefined, true)
|
|
assert.match(wgConfig, /Table = off/)
|
|
assert.doesNotMatch(wgConfig, /PostUp|PreDown/)
|
|
assert.match(wgConfig, /0\.0\.0\.0\/0/)
|
|
assert.match(ixWireguardClientTemplate(binding, wg.peerPublicKey!, bundle.destinations), /Table = auto/)
|
|
const greConfig = ixGreClientTemplate({ name: "gre-test", kind: "gre-ipsec", linux, prefixes: [],
|
|
localEndpoint: gre.endpoint, endpoint: linux.peerEndpoint, provisionGre: {
|
|
localAddress: gre.probe + "/30", peerAddress: gre.address, credentialId: bundle.id,
|
|
} }, 17, undefined, undefined, true)
|
|
assert.match(greConfig.template, /start_action = trap/)
|
|
assert.match(greConfig.setup, /systemctl enable --now ix-gre-/)
|
|
assert.match(greConfig.setup, /ExecStart=.*ip address add 10\.123\.2\.2\/32/)
|
|
assert.doesNotMatch(greConfig.setup, /ip -[46] rule|route replace|secret =/)
|
|
})
|