Files
homelab-configs/_test_api.py
T

54 lines
1.7 KiB
Python

"""Test alle dashboard API endpoints."""
import urllib.request, json
BASE = "http://127.0.0.1:8765"
def get(path):
try:
r = urllib.request.urlopen(f"{BASE}{path}", timeout=10)
return json.loads(r.read())
except Exception as e:
return {"error": str(e)}
print("=== Health ===")
print(get("/api/health"))
print("\n=== Dashboard Overview ===")
o = get("/api/dashboard/overview")
print(f"Favorites: {o.get('favorites_count')}, Passwords: {o.get('password_count')}, Network: {o.get('network_devices')}")
print("\n=== Dashboard Config ===")
c = get("/api/dashboard/config")
print(f"Settings: {list(c.get('settings',{}).keys())}")
print(f"Connections: {list(c.get('connections',{}).keys())}")
print(f"Counts: {c.get('counts')}")
print(f"Neo4j available: {c.get('connections',{}).get('neo4j',{}).get('available')}")
print("\n=== Dashboard Network ===")
n = get("/api/dashboard/network")
if "error" in n:
print(f"ERROR: {n['error']}")
else:
print(f"Devices: {n['summary']['total_devices']}")
print(f"Ports: {n['summary']['total_ports']}")
print(f"OS categories: {list(n['summary']['os_categories'].keys())[:5]}")
print("\n=== Dashboard Systems ===")
s = get("/api/dashboard/systems")
if isinstance(s, list):
print(f"Systems: {len(s)}")
if s:
print(f"First: {s[0]['ip']} - {s[0]['hostname']}")
else:
print(f"Error: {s}")
print("\n=== System Detail (192.168.1.211) ===")
d = get("/api/dashboard/systems/192.168.1.211")
print(f"IP: {d.get('ip')}, OS: {d.get('os_guess')}, Ports: {len(d.get('ports',[]))}")
print("\n=== Favorites ===")
f = get("/api/dashboard/favorites")
print(f"{len(f)} favorieten")
print("\n[OK] Alle endpoints getest!")