diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index f026584ca..367433cb6 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -121,7 +121,8 @@ class ControlClient(object): @staticmethod def set_proxies(proxy_find): """ - Note: Proxy schema changes which causes the machine to not open a tunnel back. + Note: The proxy schema changes between different versions of requests and urllib3, + which causes the machine to not open a tunnel back. If we get "ValueError: check_hostname requires server_hostname" or "Proxy URL had not schema, should start with http:// or https://" errors, the proxy schema needs to be changed. diff --git a/monkey/infection_monkey/network/httpfinger.py b/monkey/infection_monkey/network/httpfinger.py index f7ffc54e5..3939fc7c6 100644 --- a/monkey/infection_monkey/network/httpfinger.py +++ b/monkey/infection_monkey/network/httpfinger.py @@ -44,7 +44,7 @@ class HTTPFinger(HostFinger): logger.info("Port %d is open on host %s " % (port[0], host)) break # https will be the same on the same port except Timeout: - logger.debug(f"Timout while requesting headers from {url}") + logger.debug(f"Timeout while requesting headers from {url}") except ConnectionError: # Someone doesn't like us logger.debug(f"Connection error while requesting headers from {url}") diff --git a/monkey/tests/unit_tests/infection_monkey/test_control.py b/monkey/tests/unit_tests/infection_monkey/test_control.py index 81cfc93fe..7c2f42d19 100644 --- a/monkey/tests/unit_tests/infection_monkey/test_control.py +++ b/monkey/tests/unit_tests/infection_monkey/test_control.py @@ -2,17 +2,15 @@ import pytest from monkey.infection_monkey.control import ControlClient -PROXY_FOUND = ("8.8.8.8", "45455") - -@pytest.mark.parametrize("is_windows_os", [True, False]) -def test_control_set_proxies(monkeypatch, is_windows_os): +@pytest.mark.parametrize( + "is_windows_os,expected_proxy_string", + [(True, "http://8.8.8.8:45455"), (False, "8.8.8.8:45455")], +) +def test_control_set_proxies(monkeypatch, is_windows_os, expected_proxy_string): monkeypatch.setattr("monkey.infection_monkey.control.is_windows_os", lambda: is_windows_os) control_client = ControlClient() - control_client.set_proxies(PROXY_FOUND) + control_client.set_proxies(("8.8.8.8", "45455")) - if is_windows_os: - assert control_client.proxies["https"].startswith("http://") - else: - assert control_client.proxies["https"].startswith(PROXY_FOUND[0]) + assert control_client.proxies["https"] == expected_proxy_string