|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { |
| 3 | + assertGatewayLoopbackLanProof, |
| 4 | + parseGatewayLoopbackLanOptions, |
| 5 | + runGatewayLoopbackLanProof, |
| 6 | + type GatewayLoopbackLanProof, |
| 7 | +} from "./gateway-loopback-lan-access.js"; |
| 8 | + |
| 9 | +describe("Gateway loopback and LAN access producer", () => { |
| 10 | + it("parses the evidence artifact directory", () => { |
| 11 | + expect( |
| 12 | + parseGatewayLoopbackLanOptions(["--artifact-base", ".artifacts/gateway-network"]) |
| 13 | + .artifactBase, |
| 14 | + ).toContain(".artifacts/gateway-network"); |
| 15 | + expect(() => parseGatewayLoopbackLanOptions([])).toThrow("--artifact-base is required"); |
| 16 | + expect(() => parseGatewayLoopbackLanOptions(["--other", "value"])).toThrow("unknown argument"); |
| 17 | + }); |
| 18 | + |
| 19 | + it("rejects incomplete network proof", () => { |
| 20 | + const incomplete: GatewayLoopbackLanProof = { |
| 21 | + loopback: { |
| 22 | + authenticatedHealthRpc: true, |
| 23 | + healthStatus: 200, |
| 24 | + invalidTokenRejected: true, |
| 25 | + isolatedFromLanInterface: false, |
| 26 | + }, |
| 27 | + lan: { |
| 28 | + authenticatedHealthRpc: true, |
| 29 | + healthStatus: 200, |
| 30 | + invalidTokenRejected: true, |
| 31 | + nonLoopbackInterface: true, |
| 32 | + reachableThroughInterface: true, |
| 33 | + }, |
| 34 | + }; |
| 35 | + expect(() => assertGatewayLoopbackLanProof(incomplete)).toThrow("loopback isolation from LAN"); |
| 36 | + }); |
| 37 | + |
| 38 | + it("proves real loopback isolation, LAN reachability, and shared-token authentication", async () => { |
| 39 | + const proof = await runGatewayLoopbackLanProof(); |
| 40 | + expect(proof).toEqual({ |
| 41 | + loopback: { |
| 42 | + authenticatedHealthRpc: true, |
| 43 | + healthStatus: 200, |
| 44 | + invalidTokenRejected: true, |
| 45 | + isolatedFromLanInterface: true, |
| 46 | + }, |
| 47 | + lan: { |
| 48 | + authenticatedHealthRpc: true, |
| 49 | + healthStatus: 200, |
| 50 | + invalidTokenRejected: true, |
| 51 | + nonLoopbackInterface: true, |
| 52 | + reachableThroughInterface: true, |
| 53 | + }, |
| 54 | + }); |
| 55 | + }, 120_000); |
| 56 | +}); |
0 commit comments