Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(security): keep proxy-clearing fixtures hermetic on hosts with OS-level proxies
ggbond524e96ff6833
diff --git a/tests/security/test_security_network.py b/tests/security/test_security_network.pyindex 25b64631b..3a998e71d 100644--- a/tests/security/test_security_network.py+++ b/tests/security/test_security_network.py@@ -5,6 +5,7 @@ from __future__ import annotationsimport ipaddressimport socketfrom unittest.mock import patch+from urllib.request import getproxies_environmentimport pytest@@ -42,6 +43,9 @@ def test_is_loopback_host_rejects_network_targets(host: str) -> None:def _clear_proxy_env(monkeypatch: pytest.MonkeyPatch) -> None:for name in (*_PROXY_ENV_VARS, "NO_PROXY", "no_proxy"):monkeypatch.delenv(name, raising=False)+ # getproxies() falls back to OS-level proxy settings (e.g. the Windows+ # registry) when no environment variables are set; keep tests hermetic.+ monkeypatch.setattr("nanobot.security.network.getproxies", getproxies_environment)def _fake_resolve(host: str, results: list[str]):diff --git a/tests/tools/test_mcp_probe.py b/tests/tools/test_mcp_probe.pyindex 0cad030ac..3ec012596 100644--- a/tests/tools/test_mcp_probe.py+++ b/tests/tools/test_mcp_probe.py@@ -4,6 +4,7 @@ from __future__ import annotationsimport asyncioimport socketfrom unittest.mock import MagicMock, patch+from urllib.request import getproxies_environmentimport httpximport pytest@@ -21,6 +22,9 @@ _PROXY_ENV_VARS = ("HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "http_proxy", "httpdef _clear_proxy_env(monkeypatch: pytest.MonkeyPatch) -> None:for name in (*_PROXY_ENV_VARS, "NO_PROXY", "no_proxy"):monkeypatch.delenv(name, raising=False)+ # getproxies() falls back to OS-level proxy settings (e.g. the Windows+ # registry) when no environment variables are set; keep tests hermetic.+ monkeypatch.setattr("nanobot.security.network.getproxies", getproxies_environment)# ---------------------------------------------------------------------------diff --git a/tests/tools/test_mcp_tool.py b/tests/tools/test_mcp_tool.pyindex 8ed4944f4..006061432 100644--- a/tests/tools/test_mcp_tool.py+++ b/tests/tools/test_mcp_tool.py@@ -6,6 +6,7 @@ import sysfrom contextlib import asynccontextmanagerfrom pathlib import Pathfrom types import ModuleType, SimpleNamespace+from urllib.request import getproxies_environmentimport httpximport pytest@@ -65,6 +66,9 @@ def fake_mcp_runtime() -> dict[str, object | None]:def _clear_proxy_env(monkeypatch: pytest.MonkeyPatch) -> None:for name in (*_PROXY_ENV_VARS, "NO_PROXY", "no_proxy"):monkeypatch.delenv(name, raising=False)+ # getproxies() falls back to OS-level proxy settings (e.g. the Windows+ # registry) when no environment variables are set; keep tests hermetic.+ monkeypatch.setattr("nanobot.security.network.getproxies", getproxies_environment)@pytest.fixture(autouse=True)diff --git a/tests/tools/test_web_fetch_security.py b/tests/tools/test_web_fetch_security.pyindex 560522b7f..9d57e70a7 100644--- a/tests/tools/test_web_fetch_security.py+++ b/tests/tools/test_web_fetch_security.py@@ -6,6 +6,7 @@ import asyncioimport jsonimport socketfrom unittest.mock import patch+from urllib.request import getproxies_environmentimport httpximport pytest@@ -28,6 +29,9 @@ _PROXY_ENV_VARS = ("HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "http_proxy", "httpdef _clear_proxy_env(monkeypatch: pytest.MonkeyPatch) -> None:for name in (*_PROXY_ENV_VARS, "NO_PROXY", "no_proxy"):monkeypatch.delenv(name, raising=False)+ # getproxies() falls back to OS-level proxy settings (e.g. the Windows+ # registry) when no environment variables are set; keep tests hermetic.+ monkeypatch.setattr("nanobot.security.network.getproxies", getproxies_environment)def _fake_resolve_private(hostname, port, family=0, type_=0):