mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
Address review comments from PR #1544
This commit is contained in:
@@ -38,6 +38,7 @@ Set these sysctls at container runtime.
|
|||||||
--sysctl net.ipv4.conf.all.arp_ignore=1 \
|
--sysctl net.ipv4.conf.all.arp_ignore=1 \
|
||||||
--sysctl net.ipv4.conf.all.arp_announce=2 \
|
--sysctl net.ipv4.conf.all.arp_announce=2 \
|
||||||
ghcr.io/netalertx/netalertx:latest
|
ghcr.io/netalertx/netalertx:latest
|
||||||
|
```
|
||||||
|
|
||||||
> **Note:** Setting `net.ipv4.conf.all.arp_ignore` and `net.ipv4.conf.all.arp_announce` may fail with "operation not permitted" unless the container is run with elevated privileges. To resolve this, you can:
|
> **Note:** Setting `net.ipv4.conf.all.arp_ignore` and `net.ipv4.conf.all.arp_announce` may fail with "operation not permitted" unless the container is run with elevated privileges. To resolve this, you can:
|
||||||
> - Use `--privileged` with `docker run`.
|
> - Use `--privileged` with `docker run`.
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
@@ -195,11 +195,14 @@ def test_devices_by_status(client, api_token, test_mac):
|
|||||||
|
|
||||||
# 3. Check favorite formatting if devFavorite = 1
|
# 3. Check favorite formatting if devFavorite = 1
|
||||||
# Update dummy device to favorite
|
# Update dummy device to favorite
|
||||||
client.post(
|
update_resp = client.post(
|
||||||
f"/device/{test_mac}",
|
f"/device/{test_mac}",
|
||||||
json={"devFavorite": 1},
|
json={"devFavorite": 1},
|
||||||
headers=auth_headers(api_token)
|
headers=auth_headers(api_token)
|
||||||
)
|
)
|
||||||
|
assert update_resp.status_code == 200
|
||||||
|
assert update_resp.json.get("success") is True
|
||||||
|
|
||||||
resp_fav = client.get("/devices/by-status?status=my", headers=auth_headers(api_token))
|
resp_fav = client.get("/devices/by-status?status=my", headers=auth_headers(api_token))
|
||||||
fav_data = next((d for d in resp_fav.json if d["id"] == test_mac), None)
|
fav_data = next((d for d in resp_fav.json if d["id"] == test_mac), None)
|
||||||
assert fav_data is not None
|
assert fav_data is not None
|
||||||
|
|||||||
@@ -30,11 +30,21 @@ def create_dummy(client, api_token, test_mac):
|
|||||||
"devType": "Router",
|
"devType": "Router",
|
||||||
"devVendor": "TestVendor",
|
"devVendor": "TestVendor",
|
||||||
}
|
}
|
||||||
client.post(f"/device/{test_mac}", json=payload, headers=auth_headers(api_token))
|
response = client.post(f"/device/{test_mac}", json=payload, headers=auth_headers(api_token))
|
||||||
|
assert response.status_code in [200, 201], (
|
||||||
|
f"Expected status 200/201 for device creation, got {response.status_code}. "
|
||||||
|
f"Response body: {response.get_data(as_text=True)}"
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def delete_dummy(client, api_token, test_mac):
|
def delete_dummy(client, api_token, test_mac):
|
||||||
client.delete("/devices", json={"macs": [test_mac]}, headers=auth_headers(api_token))
|
response = client.delete("/devices", json={"macs": [test_mac]}, headers=auth_headers(api_token))
|
||||||
|
assert response.status_code == 200, (
|
||||||
|
f"Expected status 200 for device deletion, got {response.status_code}. "
|
||||||
|
f"Response body: {response.get_data(as_text=True)}"
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
# --- Device Search Tests ---
|
# --- Device Search Tests ---
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ such as environment variable settings and check skipping.
|
|||||||
import subprocess
|
import subprocess
|
||||||
import uuid
|
import uuid
|
||||||
import pytest
|
import pytest
|
||||||
|
import shutil
|
||||||
|
|
||||||
IMAGE = "netalertx-test"
|
IMAGE = "netalertx-test"
|
||||||
|
|
||||||
@@ -94,8 +95,6 @@ def test_skip_startup_checks_env_var():
|
|||||||
|
|
||||||
@pytest.mark.docker
|
@pytest.mark.docker
|
||||||
@pytest.mark.feature_complete
|
@pytest.mark.feature_complete
|
||||||
def test_host_optimization_warning_matches_sysctl():
|
|
||||||
"""Validate host-optimization warning matches actual host sysctl values."""
|
|
||||||
def test_host_optimization_warning_matches_sysctl():
|
def test_host_optimization_warning_matches_sysctl():
|
||||||
"""Validate host-optimization warning matches actual host sysctl values."""
|
"""Validate host-optimization warning matches actual host sysctl values."""
|
||||||
sysctl_bin = shutil.which("sysctl")
|
sysctl_bin = shutil.which("sysctl")
|
||||||
@@ -116,11 +115,6 @@ def test_host_optimization_warning_matches_sysctl():
|
|||||||
check=False,
|
check=False,
|
||||||
timeout=10,
|
timeout=10,
|
||||||
)
|
)
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
check=False,
|
|
||||||
timeout=10,
|
|
||||||
)
|
|
||||||
|
|
||||||
if ignore_proc.returncode != 0 or announce_proc.returncode != 0:
|
if ignore_proc.returncode != 0 or announce_proc.returncode != 0:
|
||||||
pytest.skip("sysctl values unavailable on host; skipping host-optimization warning check")
|
pytest.skip("sysctl values unavailable on host; skipping host-optimization warning check")
|
||||||
|
|||||||
Reference in New Issue
Block a user