Files
openclaw/test/e2e/qa-lab/runtime/gateway-loopback-lan-access.test.ts
Peter Steinberger 40ef8c5e68 test(gateway): restore startup environment after servers (#120137)
* fix(test): restore gateway startup environment

* fix(test): centralize gateway startup env cleanup

* test(gateway): restore live startup environment

* fix(test): complete gateway startup env lifecycle

* test(gateway): restore raw server owner environment

* test(qa): restore gateway producer environment
2026-08-07 01:06:16 -07:00

60 lines
2.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { snapshotGatewayStartupEnv } from "../../../../src/gateway/test-helpers.env.js";
import {
assertGatewayLoopbackLanProof,
parseGatewayLoopbackLanOptions,
runGatewayLoopbackLanProof,
type GatewayLoopbackLanProof,
} from "./gateway-loopback-lan-access.js";
describe("Gateway loopback and LAN access producer", () => {
it("parses the evidence artifact directory", () => {
expect(
parseGatewayLoopbackLanOptions(["--artifact-base", ".artifacts/gateway-network"])
.artifactBase,
).toContain(".artifacts/gateway-network");
expect(() => parseGatewayLoopbackLanOptions([])).toThrow("--artifact-base is required");
expect(() => parseGatewayLoopbackLanOptions(["--other", "value"])).toThrow("unknown argument");
});
it("rejects incomplete network proof", () => {
const incomplete: GatewayLoopbackLanProof = {
loopback: {
authenticatedHealthRpc: true,
healthStatus: 200,
invalidTokenRejected: true,
isolatedFromLanInterface: false,
},
lan: {
authenticatedHealthRpc: true,
healthStatus: 200,
invalidTokenRejected: true,
nonLoopbackInterface: true,
reachableThroughInterface: true,
},
};
expect(() => assertGatewayLoopbackLanProof(incomplete)).toThrow("loopback isolation from LAN");
});
it("proves real loopback isolation, LAN reachability, and shared-token authentication", async () => {
const gatewayStartupEnv = snapshotGatewayStartupEnv();
const proof = await runGatewayLoopbackLanProof();
expect(snapshotGatewayStartupEnv()).toEqual(gatewayStartupEnv);
expect(proof).toEqual({
loopback: {
authenticatedHealthRpc: true,
healthStatus: 200,
invalidTokenRejected: true,
isolatedFromLanInterface: true,
},
lan: {
authenticatedHealthRpc: true,
healthStatus: 200,
invalidTokenRejected: true,
nonLoopbackInterface: true,
reachableThroughInterface: true,
},
});
}, 120_000);
});