Skip to content

Commit f1a87bf

Browse files
authored
test(gateway): cover loopback and LAN access (#118824)
1 parent f9d9d12 commit f1a87bf

3 files changed

Lines changed: 579 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
title: Gateway loopback and LAN access
2+
3+
scenario:
4+
id: gateway-loopback-lan-access
5+
surface: runtime
6+
coverage:
7+
primary:
8+
- gateway.loopback-and-lan-access
9+
objective: Prove that loopback binding stays host-local while LAN binding is reachable through a real non-loopback interface with Gateway authentication enforced.
10+
successCriteria:
11+
- A loopback-bound Gateway serves HTTP health and authenticated WebSocket health on 127.0.0.1.
12+
- The same loopback listener rejects a connection addressed through the host's non-loopback IPv4 interface.
13+
- A LAN-bound Gateway serves HTTP health and authenticated WebSocket health through the host's actual non-loopback IPv4 interface.
14+
- Invalid shared tokens are rejected and the valid shared token is accepted on both listener modes.
15+
docsRefs:
16+
- docs/gateway/index.md
17+
- docs/gateway/protocol.md
18+
- docs/gateway/security/index.md
19+
- docs/concepts/qa-e2e-automation.md
20+
codeRefs:
21+
- src/gateway/net.ts
22+
- src/gateway/server.ts
23+
- src/gateway/server-runtime-config.ts
24+
- test/e2e/qa-lab/runtime/gateway-loopback-lan-access.ts
25+
- test/e2e/qa-lab/runtime/gateway-loopback-lan-access.test.ts
26+
execution:
27+
kind: script
28+
path: test/e2e/qa-lab/runtime/gateway-loopback-lan-access.ts
29+
summary: Starts real loopback and LAN Gateway listeners, then probes their HTTP and WebSocket surfaces from loopback and the host's real LAN interface.
30+
args:
31+
- --artifact-base
32+
- ${outputDir}
33+
timeoutMs: 120000
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)