mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-15 15:13:48 -06:00
40ef8c5e68
* 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
60 lines
2.0 KiB
TypeScript
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);
|
|
});
|