sicherheitsupdate

This commit is contained in:
stephan
2025-06-29 08:33:19 +02:00
parent 4ed4d69b21
commit 55f6d0816c
9 changed files with 286 additions and 247 deletions

19
tests/test_api.py Normal file
View File

@ -0,0 +1,19 @@
from fastapi.testclient import TestClient
from wilcon import app
client = TestClient(app)
def test_sysinfo_endpoint():
response = client.get("/sysinfo")
assert response.status_code == 200
assert "cpu" in response.json()
def test_netinfo_endpoint():
response = client.get("/netinfo")
assert response.status_code == 200
assert "ip_address" in response.json()
def test_procinfo_endpoint():
response = client.get("/procinfo")
assert response.status_code == 200
assert isinstance(response.json(), list)

8
tests/test_netinf.py Normal file
View File

@ -0,0 +1,8 @@
from netinf import get_network_info
def test_network_info_contains_expected_keys():
data = get_network_info(debug=False)
assert isinstance(data, dict)
for key in ["hostname", "ip_address", "interfaces", "gateway", "dns_servers", "connections"]:
assert key in data

9
tests/test_proginfo.py Normal file
View File

@ -0,0 +1,9 @@
from proginfo import get_process_info
def test_process_info_returns_list():
data = get_process_info()
assert isinstance(data, list)
if data: # Teste nur, wenn Prozesse vorhanden sind
proc = data[0]
for key in ["pid", "name", "user", "cpu", "memory", "status", "start_time", "runtime_seconds"]:
assert key in proc

15
tests/test_sysinfo.py Normal file
View File

@ -0,0 +1,15 @@
from sysinfo import get_hardware_info
def test_sysinfo_contains_required_keys():
data = get_hardware_info()
assert isinstance(data, dict)
for key in ["cpu", "ram", "disk", "os", "network_basic", "user_accounts", "gpu"]:
assert key in data
def test_cpu_info_structure():
cpu = get_hardware_info()["cpu"]
assert "model" in cpu
assert "cores" in cpu
assert "threads" in cpu
assert "usage" in cpu