From a8182cbb3dc4f3441196d7239b62c11e9e845464 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 7 Oct 2021 10:50:41 +0200 Subject: [PATCH] UT: Add test for settting agent proxy --- .../infection_monkey/test_control.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 monkey/tests/unit_tests/infection_monkey/test_control.py diff --git a/monkey/tests/unit_tests/infection_monkey/test_control.py b/monkey/tests/unit_tests/infection_monkey/test_control.py new file mode 100644 index 000000000..81cfc93fe --- /dev/null +++ b/monkey/tests/unit_tests/infection_monkey/test_control.py @@ -0,0 +1,18 @@ +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): + monkeypatch.setattr("monkey.infection_monkey.control.is_windows_os", lambda: is_windows_os) + control_client = ControlClient() + + control_client.set_proxies(PROXY_FOUND) + + if is_windows_os: + assert control_client.proxies["https"].startswith("http://") + else: + assert control_client.proxies["https"].startswith(PROXY_FOUND[0])