Scrub real LAN addresses, MACs and name from docs and test fixtures

This commit is contained in:
neil 2026-11-05 01:29:45 -08:00
parent c9738358de
commit 3d0e4bd153
6 changed files with 20 additions and 20 deletions

View file

@ -57,7 +57,7 @@ def handler(request: httpx.Request) -> httpx.Response:
})
if p == "/control/clients":
return httpx.Response(200, json={
"clients": [{"name": "Neil's laptop", "ids": ["192.168.1.5", "AA:BB:CC:DD:EE:01"]}],
"clients": [{"name": "Test laptop", "ids": ["192.168.1.5", "AA:BB:CC:DD:EE:01"]}],
"auto_clients": [{"ip": "192.168.1.50", "name": "tv.lan", "source": "rDNS"}],
})
if p == "/control/dhcp/status":
@ -90,7 +90,7 @@ def test_discovery_merges_sources(hub, ag):
asyncio.run(dns.discover_once())
clients = {c["key"]: c for c in hub.get("/api/clients").json()["clients"]}
laptop = clients["aa:bb:cc:dd:ee:01"]
assert laptop["ip"] == "192.168.1.5" and laptop["hostname"] in ("Neil's laptop", "host-5")
assert laptop["ip"] == "192.168.1.5" and laptop["hostname"] in ("Test laptop", "host-5")
assert laptop["online"] and laptop["queries"] == 660 and "adguard" in laptop["sources"]
assert not laptop["new"] # found on the first day: not flagged as new
assert clients["aa:bb:cc:dd:ee:02"]["hostname"] == "plug"

View file

@ -73,7 +73,7 @@ pct() {{ echo "pct $*" >> {log}; case $1 in
config) [ "$2" = 100 ] && echo "tags: web"; [ "$2" = 105 ] && printf 'hostname: netmon-hub\\ntags: netmon-hub\\n'; true ;;
status) echo "status: stopped" ;;
push) cp "$3" {pushed} ;;
exec) shift 3; [ "$1" = hostname ] && echo "192.168.68.50 "; true ;;
exec) shift 3; [ "$1" = hostname ] && echo "10.9.8.50 "; true ;;
esac; }}
pvesh() {{ echo "pvesh $*" >> {log}; echo 105; }}
pveam() {{ echo "pveam $*" >> {log}; [ "$1" = available ] && printf "system debian-12-standard_12.7-1_amd64.tar.zst\\nsystem debian-12-standard_12.12-1_amd64.tar.zst\\n"; true; }}
@ -101,7 +101,7 @@ export -f pct pvesh pveam pvesm sleep id
# Native inside, port 80 for the .local name, a locale the container has, one summary.
for part in ("INSTALL_MODE=native", "HOST_PORT=80", "LC_ALL=C.UTF-8", "LANG=C.UTF-8", "NETMON_NESTED=1"):
assert part in inner, part
assert "http://netmon-hub.local (or http://192.168.68.50)" in r.stdout
assert "http://netmon-hub.local (or http://10.9.8.50)" in r.stdout
assert "pct exec 105 -- network-monitor-update" in r.stdout # works because setup.sh links it into /usr/bin
# The pushed script is a complete installer for the same role.
text = pushed.read_text()

View file

@ -113,20 +113,20 @@ def test_macos_parsers():
route = """ route to: default
destination: default
mask: default
gateway: 192.168.68.1
gateway: 10.9.8.1
interface: en0
flags: <UP,GATEWAY,DONE,STATIC,PRCLONING,GLOBAL>
"""
assert checks.parse_route_get(route) == "192.168.68.1"
assert checks.parse_route_get(route) == "10.9.8.1"
assert checks.parse_route_get("route: writing to routing socket: not in table\n") is None
arp = """? (192.168.68.1) at 0:ef:15:97:fc:1e on en0 ifscope [ethernet]
? (192.168.68.20) at e0:51:d8:1c:5f:96 on en0 ifscope [ethernet]
? (192.168.68.77) at (incomplete) on en0 ifscope [ethernet]
? (192.168.68.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]
? (192.168.64.2) at 2a:1:3:4:5:6 on bridge100 ifscope [bridge]
arp = """? (10.9.8.1) at 0:02:aa:bb:1c:3d on en0 ifscope [ethernet]
? (10.9.8.20) at 2:51:d8:1c:5f:96 on en0 ifscope [ethernet]
? (10.9.8.77) at (incomplete) on en0 ifscope [ethernet]
? (10.9.8.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]
? (10.9.7.2) at 2a:1:3:4:5:6 on bridge100 ifscope [bridge]
? (224.0.0.251) at 1:0:5e:0:0:fb on en0 ifscope permanent [ethernet]
"""
assert checks.parse_arp_an(arp) == [
{"ip": "192.168.68.1", "mac": "00:ef:15:97:fc:1e"},
{"ip": "192.168.68.20", "mac": "e0:51:d8:1c:5f:96"},
{"ip": "10.9.8.1", "mac": "00:02:aa:bb:1c:3d"},
{"ip": "10.9.8.20", "mac": "02:51:d8:1c:5f:96"},
]