mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-30 23:03:03 -07:00
Address review comments from PR #1544
This commit is contained in:
@@ -38,7 +38,8 @@ Set these sysctls at container runtime.
|
||||
--sysctl net.ipv4.conf.all.arp_ignore=1 \
|
||||
--sysctl net.ipv4.conf.all.arp_announce=2 \
|
||||
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:
|
||||
> - Use `--privileged` with `docker run`.
|
||||
> - Use the more restrictive `--cap-add=NET_ADMIN` (or `cap_add: [NET_ADMIN]` in `docker-compose` service definitions) to allow the sysctls to be applied at runtime.
|
||||
|
||||
0
install/production-filesystem/entrypoint.d/36-override-individual-settings.sh
Normal file → Executable file
0
install/production-filesystem/entrypoint.d/36-override-individual-settings.sh
Normal file → Executable file
0
install/production-filesystem/entrypoint.d/37-host-optimization.sh
Normal file → Executable file
0
install/production-filesystem/entrypoint.d/37-host-optimization.sh
Normal file → Executable file
@@ -195,11 +195,14 @@ def test_devices_by_status(client, api_token, test_mac):
|
||||
|
||||
# 3. Check favorite formatting if devFavorite = 1
|
||||
# Update dummy device to favorite
|
||||
client.post(
|
||||
update_resp = client.post(
|
||||
f"/device/{test_mac}",
|
||||
json={"devFavorite": 1},
|
||||
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))
|
||||
fav_data = next((d for d in resp_fav.json if d["id"] == test_mac), None)
|
||||
assert fav_data is not None
|
||||
|
||||
@@ -30,11 +30,21 @@ def create_dummy(client, api_token, test_mac):
|
||||
"devType": "Router",
|
||||
"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):
|
||||
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 ---
|
||||
|
||||
@@ -8,6 +8,7 @@ such as environment variable settings and check skipping.
|
||||
import subprocess
|
||||
import uuid
|
||||
import pytest
|
||||
import shutil
|
||||
|
||||
IMAGE = "netalertx-test"
|
||||
|
||||
@@ -85,7 +86,7 @@ def test_no_app_conf_override_when_no_graphql_port():
|
||||
|
||||
def test_skip_startup_checks_env_var():
|
||||
# If SKIP_STARTUP_CHECKS contains the human-readable name of a check (e.g. "mandatory folders"),
|
||||
# the entrypoint should skip that specific check. We check that the "Creating NetAlertX log directory."
|
||||
# the entrypoint should skip that specific check. We check that the "Creating NetAlertX log directory."
|
||||
# message (from the mandatory folders check) is not printed when skipped.
|
||||
result = _run_entrypoint(env={"SKIP_STARTUP_CHECKS": "mandatory folders"}, check_only=True)
|
||||
assert "Creating NetAlertX log directory" not in result.stdout
|
||||
@@ -94,8 +95,6 @@ def test_skip_startup_checks_env_var():
|
||||
|
||||
@pytest.mark.docker
|
||||
@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():
|
||||
"""Validate host-optimization warning matches actual host sysctl values."""
|
||||
sysctl_bin = shutil.which("sysctl")
|
||||
@@ -116,11 +115,6 @@ def test_host_optimization_warning_matches_sysctl():
|
||||
check=False,
|
||||
timeout=10,
|
||||
)
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
if ignore_proc.returncode != 0 or announce_proc.returncode != 0:
|
||||
pytest.skip("sysctl values unavailable on host; skipping host-optimization warning check")
|
||||
|
||||
Reference in New Issue
Block a user