From b85420659904852abf14b4d75214848f101b7d9b Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Wed, 4 Mar 2026 14:36:31 +0000 Subject: [PATCH] Address review comments from PR #1544 --- docs/docker-troubleshooting/arp-flux-sysctls.md | 3 ++- .../36-override-individual-settings.sh | 0 .../entrypoint.d/37-host-optimization.sh | 0 test/api_endpoints/test_devices_endpoints.py | 5 ++++- test/api_endpoints/test_mcp_tools_endpoints.py | 14 ++++++++++++-- test/docker_tests/test_entrypoint.py | 10 ++-------- 6 files changed, 20 insertions(+), 12 deletions(-) mode change 100644 => 100755 install/production-filesystem/entrypoint.d/36-override-individual-settings.sh mode change 100644 => 100755 install/production-filesystem/entrypoint.d/37-host-optimization.sh diff --git a/docs/docker-troubleshooting/arp-flux-sysctls.md b/docs/docker-troubleshooting/arp-flux-sysctls.md index 958118de..1070659a 100644 --- a/docs/docker-troubleshooting/arp-flux-sysctls.md +++ b/docs/docker-troubleshooting/arp-flux-sysctls.md @@ -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. diff --git a/install/production-filesystem/entrypoint.d/36-override-individual-settings.sh b/install/production-filesystem/entrypoint.d/36-override-individual-settings.sh old mode 100644 new mode 100755 diff --git a/install/production-filesystem/entrypoint.d/37-host-optimization.sh b/install/production-filesystem/entrypoint.d/37-host-optimization.sh old mode 100644 new mode 100755 diff --git a/test/api_endpoints/test_devices_endpoints.py b/test/api_endpoints/test_devices_endpoints.py index 4dd2a4ab..62a3725c 100644 --- a/test/api_endpoints/test_devices_endpoints.py +++ b/test/api_endpoints/test_devices_endpoints.py @@ -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 diff --git a/test/api_endpoints/test_mcp_tools_endpoints.py b/test/api_endpoints/test_mcp_tools_endpoints.py index 489c1e3b..cdf2a94a 100644 --- a/test/api_endpoints/test_mcp_tools_endpoints.py +++ b/test/api_endpoints/test_mcp_tools_endpoints.py @@ -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 --- diff --git a/test/docker_tests/test_entrypoint.py b/test/docker_tests/test_entrypoint.py index a2533765..94a29a8a 100644 --- a/test/docker_tests/test_entrypoint.py +++ b/test/docker_tests/test_entrypoint.py @@ -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")