From 9da1ad4c4674d69e01597c44413fe70684704cbd Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 14:54:25 +0530 Subject: [PATCH 01/14] Agent: Pass and accept island_api_client in CachingAgentBinaryRepository's constructor --- .../exploit/caching_agent_binary_repository.py | 4 +++- monkey/infection_monkey/monkey.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index 745aae112..72ff61446 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -6,6 +6,7 @@ import requests from common import OperatingSystem from common.common_consts.timeouts import MEDIUM_REQUEST_TIMEOUT +from infection_monkey.island_api_client import IIslandAPIClient from . import IAgentBinaryRepository @@ -17,9 +18,10 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): request is actually sent to the island for each requested binary. """ - def __init__(self, island_url: str): + def __init__(self, island_url: str, island_api_client: IIslandAPIClient): self._island_url = island_url self._lock = threading.Lock() + self._island_api_client = island_api_client def get_agent_binary( self, operating_system: OperatingSystem, architecture: str = None diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 96da82225..6a7e1cfb1 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -111,12 +111,12 @@ class InfectionMonkey: self._opts = self._get_arguments(args) # TODO: Revisit variable names - server, island_api_client = self._connect_to_island_api() + server, self.island_api_client = self._connect_to_island_api() # TODO: `address_to_port()` should return the port as an integer. self._cmd_island_ip, self._cmd_island_port = address_to_ip_port(server) self._cmd_island_port = int(self._cmd_island_port) self._control_client = ControlClient( - server_address=server, island_api_client=island_api_client + server_address=server, island_api_client=self.island_api_client ) # TODO Refactor the telemetry messengers to accept control client @@ -315,7 +315,8 @@ class InfectionMonkey: puppet.load_plugin("ssh", SSHFingerprinter(), PluginType.FINGERPRINTER) agent_binary_repository = CachingAgentBinaryRepository( - f"https://{self._control_client.server_address}" + island_url=f"https://{self._control_client.server_address}", + island_api_client=self.island_api_client, ) exploit_wrapper = ExploiterWrapper( self._telemetry_messenger, event_queue, agent_binary_repository From 1355c038b5970f4f59294420bcf750ef2d420743 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 14:56:10 +0530 Subject: [PATCH 02/14] Agent: Add and use HTTPIslandAPIClient.get_agent_binary() --- .../exploit/caching_agent_binary_repository.py | 14 +------------- .../island_api_client/http_island_api_client.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index 72ff61446..f74648eff 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -2,10 +2,7 @@ import io import threading from functools import lru_cache -import requests - from common import OperatingSystem -from common.common_consts.timeouts import MEDIUM_REQUEST_TIMEOUT from infection_monkey.island_api_client import IIslandAPIClient from . import IAgentBinaryRepository @@ -36,13 +33,4 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): @lru_cache(maxsize=None) def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes: os_name = operating_system.value - - response = requests.get( # noqa: DUO123 - f"{self._island_url}/api/agent-binaries/{os_name}", - verify=False, - timeout=MEDIUM_REQUEST_TIMEOUT, - ) - - response.raise_for_status() - - return response.content + return self._island_api_client.get_agent_binary(os_name) diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index 37feb8942..92ac1ce41 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -76,3 +76,14 @@ class HTTPIslandAPIClient(IIslandAPIClient): response.raise_for_status() return response.content + + @handle_island_errors + def get_agent_binary(self, os_name: str): + response = requests.get( # noqa: DUO123 + f"{self._api_url}/api/agent-binaries/{os_name}", + verify=False, + timeout=MEDIUM_REQUEST_TIMEOUT, + ) + response.raise_for_status() + + return response.content From e23c6de745af452d1fdb1c1850873690fc9e8f1e Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 14:59:35 +0530 Subject: [PATCH 03/14] Agent: Remove no longer needed `island_url` parameter from CachingAgentBinaryRepository --- .../exploit/caching_agent_binary_repository.py | 3 +-- monkey/infection_monkey/monkey.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index f74648eff..e7f00c54b 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -15,8 +15,7 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): request is actually sent to the island for each requested binary. """ - def __init__(self, island_url: str, island_api_client: IIslandAPIClient): - self._island_url = island_url + def __init__(self, island_api_client: IIslandAPIClient): self._lock = threading.Lock() self._island_api_client = island_api_client diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 6a7e1cfb1..e53610326 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -315,7 +315,6 @@ class InfectionMonkey: puppet.load_plugin("ssh", SSHFingerprinter(), PluginType.FINGERPRINTER) agent_binary_repository = CachingAgentBinaryRepository( - island_url=f"https://{self._control_client.server_address}", island_api_client=self.island_api_client, ) exploit_wrapper = ExploiterWrapper( From 3b3f39065d2536ccdbf631267f73c52d3024475b Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 15:14:28 +0530 Subject: [PATCH 04/14] Agent: Remove comment no longer relevant from monkey.py --- monkey/infection_monkey/monkey.py | 1 - 1 file changed, 1 deletion(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index e53610326..baaa1ea54 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -110,7 +110,6 @@ class InfectionMonkey: self._singleton = SystemSingleton() self._opts = self._get_arguments(args) - # TODO: Revisit variable names server, self.island_api_client = self._connect_to_island_api() # TODO: `address_to_port()` should return the port as an integer. self._cmd_island_ip, self._cmd_island_port = address_to_ip_port(server) From 460572287407e79f7ca693fec3778c20a2e06147 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 15:18:03 +0530 Subject: [PATCH 05/14] Agent: Add logging in CachingAgentBinaryRepository._download_binary_from_island() --- .../exploit/caching_agent_binary_repository.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index e7f00c54b..1a52806f0 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -1,4 +1,5 @@ import io +import logging import threading from functools import lru_cache @@ -7,6 +8,8 @@ from infection_monkey.island_api_client import IIslandAPIClient from . import IAgentBinaryRepository +logger = logging.getLogger(__name__) + class CachingAgentBinaryRepository(IAgentBinaryRepository): """ @@ -32,4 +35,7 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): @lru_cache(maxsize=None) def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes: os_name = operating_system.value - return self._island_api_client.get_agent_binary(os_name) + try: + return self._island_api_client.get_agent_binary(os_name) + except Exception as exc: + logger.warning(f"Error connecting to control server: {exc}") From d84550ba23b6a0ae6e2aba38e2d16d216c9423f3 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 15:19:34 +0530 Subject: [PATCH 06/14] Agent: Fix return type hint in CachingAgentBinaryRepository._download_binary_from_island() --- .../exploit/caching_agent_binary_repository.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index 1a52806f0..46e752470 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -2,6 +2,7 @@ import io import logging import threading from functools import lru_cache +from typing import Optional from common import OperatingSystem from infection_monkey.island_api_client import IIslandAPIClient @@ -33,9 +34,10 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): return io.BytesIO(self._download_binary_from_island(operating_system)) @lru_cache(maxsize=None) - def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes: + def _download_binary_from_island(self, operating_system: OperatingSystem) -> Optional[bytes]: os_name = operating_system.value try: return self._island_api_client.get_agent_binary(os_name) except Exception as exc: logger.warning(f"Error connecting to control server: {exc}") + return None From 2cebc19843079039f088a74edd007521071b39f4 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 17:21:31 +0530 Subject: [PATCH 07/14] Agent: Add get_agent_binary() to the IIslandAPIClient interface --- .../island_api_client/i_island_api_client.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/monkey/infection_monkey/island_api_client/i_island_api_client.py b/monkey/infection_monkey/island_api_client/i_island_api_client.py index fefba9973..fea93d1dc 100644 --- a/monkey/infection_monkey/island_api_client/i_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/i_island_api_client.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +from typing import Optional class IIslandAPIClient(ABC): @@ -54,3 +55,20 @@ class IIslandAPIClient(ABC): :raises IslandAPIError: If an unexpected error occurs while attempting to retrieve the custom PBA file """ + + @abstractmethod + def get_agent_binary(self, os_name: str) -> Optional[bytes]: + """ + Get an agent binary for the given OS from the island + + :param os_name: The OS on which the agent binary will run + :return: The agent binary file + :raises IslandAPIConnectionError: If the client cannot successfully connect to the island + :raises IslandAPIRequestError: If an error occurs while attempting to connect to the + island due to an issue in the request sent from the client + :raises IslandAPIRequestFailedError: If an error occurs while attempting to connect to the + island due to an error on the server + :raises IslandAPITimeoutError: If a timeout occurs while attempting to connect to the island + :raises IslandAPIError: If an unexpected error occurs while attempting to retrieve the + agent binary + """ From 30cf360e983bb729c4b2cdd09b6a33308ffc748f Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 17:27:47 +0530 Subject: [PATCH 08/14] Agent: Fix URL in HTTPIslandAPIClient.get_agent_binary() --- .../island_api_client/http_island_api_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index 92ac1ce41..7c8cab1ab 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -80,7 +80,7 @@ class HTTPIslandAPIClient(IIslandAPIClient): @handle_island_errors def get_agent_binary(self, os_name: str): response = requests.get( # noqa: DUO123 - f"{self._api_url}/api/agent-binaries/{os_name}", + f"{self._api_url}/agent-binaries/{os_name}", verify=False, timeout=MEDIUM_REQUEST_TIMEOUT, ) From e8ecaa2169b633f3667263821f05080317015a22 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 17:28:22 +0530 Subject: [PATCH 09/14] UT: Add tests for HTTPIslandAPIClient.get_agent_binary() --- .../test_http_island_api_client.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py index bd6bfcb41..b18f3990b 100644 --- a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py +++ b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py @@ -13,10 +13,12 @@ from infection_monkey.island_api_client import ( SERVER = "1.1.1.1:9999" PBA_FILE = "dummy.pba" +WINDOWS = "windows" ISLAND_URI = f"https://{SERVER}/api?action=is-up" ISLAND_SEND_LOG_URI = f"https://{SERVER}/api/log" ISLAND_GET_PBA_FILE_URI = f"https://{SERVER}/api/pba/download/{PBA_FILE}" +ISLAND_GET_AGENT_BINARY_URI = f"https://{SERVER}/api/agent-binaries/{WINDOWS}" @pytest.mark.parametrize( @@ -118,3 +120,38 @@ def test_island_api_client_get_pba_file__status_code(status_code, expected_error with pytest.raises(expected_error): m.get(ISLAND_GET_PBA_FILE_URI, status_code=status_code) island_api_client.get_pba_file(filename=PBA_FILE) + + +@pytest.mark.parametrize( + "actual_error, expected_error", + [ + (requests.exceptions.ConnectionError, IslandAPIConnectionError), + (TimeoutError, IslandAPITimeoutError), + (Exception, IslandAPIError), + ], +) +def test_island_api_client__get_agent_binary(actual_error, expected_error): + with requests_mock.Mocker() as m: + m.get(ISLAND_URI) + island_api_client = HTTPIslandAPIClient(SERVER) + + with pytest.raises(expected_error): + m.get(ISLAND_GET_AGENT_BINARY_URI, exc=actual_error) + island_api_client.get_agent_binary(os_name=WINDOWS) + + +@pytest.mark.parametrize( + "status_code, expected_error", + [ + (401, IslandAPIRequestError), + (501, IslandAPIRequestFailedError), + ], +) +def test_island_api_client__get_agent_binary_status_code(status_code, expected_error): + with requests_mock.Mocker() as m: + m.get(ISLAND_URI) + island_api_client = HTTPIslandAPIClient(SERVER) + + with pytest.raises(expected_error): + m.get(ISLAND_GET_AGENT_BINARY_URI, status_code=status_code) + island_api_client.get_agent_binary(os_name=WINDOWS) From 0e9397b283de24b9a97b94cab0cfbef55577cf2b Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 18:30:21 +0530 Subject: [PATCH 10/14] Agent: Add RetrievalError to i_agent_binary_repository.py --- .../infection_monkey/exploit/i_agent_binary_repository.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/monkey/infection_monkey/exploit/i_agent_binary_repository.py b/monkey/infection_monkey/exploit/i_agent_binary_repository.py index 09de7a696..b78888864 100644 --- a/monkey/infection_monkey/exploit/i_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/i_agent_binary_repository.py @@ -7,6 +7,12 @@ from common import OperatingSystem # moment, the Island and Agent have different needs, but at some point we should unify these. +class RetrievalError(RuntimeError): + """ + Raised when a repository encounters an error while attempting to retrieve data + """ + + class IAgentBinaryRepository(metaclass=abc.ABCMeta): """ IAgentBinaryRepository provides an interface for other components to access agent binaries. @@ -23,5 +29,6 @@ class IAgentBinaryRepository(metaclass=abc.ABCMeta): :param operating_system: The name of the operating system on which the agent binary will run :param architecture: Reserved :return: A file-like object for the requested agent binary + :raises RetrievalError: If an error occurs when retrieving the agent binary """ pass From 088e020fee14b9184fae1780f941e80b920d4b16 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 18:31:57 +0530 Subject: [PATCH 11/14] Agent: Catch IslandAPIError and raise RetrievalError in CachingAgentBinaryRepository._download_binary_from_island() --- monkey/infection_monkey/exploit/__init__.py | 2 +- .../exploit/caching_agent_binary_repository.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/monkey/infection_monkey/exploit/__init__.py b/monkey/infection_monkey/exploit/__init__.py index 195e880ad..22d1fc865 100644 --- a/monkey/infection_monkey/exploit/__init__.py +++ b/monkey/infection_monkey/exploit/__init__.py @@ -1,3 +1,3 @@ -from .i_agent_binary_repository import IAgentBinaryRepository +from .i_agent_binary_repository import IAgentBinaryRepository, RetrievalError from .caching_agent_binary_repository import CachingAgentBinaryRepository from .exploiter_wrapper import ExploiterWrapper diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index 46e752470..8af4b7a4d 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -2,12 +2,11 @@ import io import logging import threading from functools import lru_cache -from typing import Optional from common import OperatingSystem -from infection_monkey.island_api_client import IIslandAPIClient +from infection_monkey.island_api_client import IIslandAPIClient, IslandAPIError -from . import IAgentBinaryRepository +from . import IAgentBinaryRepository, RetrievalError logger = logging.getLogger(__name__) @@ -34,10 +33,9 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): return io.BytesIO(self._download_binary_from_island(operating_system)) @lru_cache(maxsize=None) - def _download_binary_from_island(self, operating_system: OperatingSystem) -> Optional[bytes]: + def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes: os_name = operating_system.value try: return self._island_api_client.get_agent_binary(os_name) - except Exception as exc: - logger.warning(f"Error connecting to control server: {exc}") - return None + except IslandAPIError as err: + raise RetrievalError(err) From 9b3950e8ebaf3181234bf6ef537be2dc8360c2ae Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 18:34:05 +0530 Subject: [PATCH 12/14] Agent: Accept OperatingSystem instead of str in HTTPIslandAPIClientget_agent_binary() --- .../exploit/caching_agent_binary_repository.py | 3 +-- .../island_api_client/http_island_api_client.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py index 8af4b7a4d..1d8067da3 100644 --- a/monkey/infection_monkey/exploit/caching_agent_binary_repository.py +++ b/monkey/infection_monkey/exploit/caching_agent_binary_repository.py @@ -34,8 +34,7 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository): @lru_cache(maxsize=None) def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes: - os_name = operating_system.value try: - return self._island_api_client.get_agent_binary(os_name) + return self._island_api_client.get_agent_binary(operating_system) except IslandAPIError as err: raise RetrievalError(err) diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index 7c8cab1ab..3b2adfe61 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -3,6 +3,7 @@ import logging import requests +from common import OperatingSystem from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT from . import ( @@ -78,7 +79,8 @@ class HTTPIslandAPIClient(IIslandAPIClient): return response.content @handle_island_errors - def get_agent_binary(self, os_name: str): + def get_agent_binary(self, operating_system: OperatingSystem): + os_name = operating_system.value response = requests.get( # noqa: DUO123 f"{self._api_url}/agent-binaries/{os_name}", verify=False, From 2bd64a31755cddd65e929d009300683b01aa39bf Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 18:38:09 +0530 Subject: [PATCH 13/14] Agent: Make variable `island_api_client` protected in InfectionMonkey --- monkey/infection_monkey/monkey.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index baaa1ea54..21b115735 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -110,12 +110,12 @@ class InfectionMonkey: self._singleton = SystemSingleton() self._opts = self._get_arguments(args) - server, self.island_api_client = self._connect_to_island_api() + server, self._island_api_client = self._connect_to_island_api() # TODO: `address_to_port()` should return the port as an integer. self._cmd_island_ip, self._cmd_island_port = address_to_ip_port(server) self._cmd_island_port = int(self._cmd_island_port) self._control_client = ControlClient( - server_address=server, island_api_client=self.island_api_client + server_address=server, island_api_client=self._island_api_client ) # TODO Refactor the telemetry messengers to accept control client @@ -314,7 +314,7 @@ class InfectionMonkey: puppet.load_plugin("ssh", SSHFingerprinter(), PluginType.FINGERPRINTER) agent_binary_repository = CachingAgentBinaryRepository( - island_api_client=self.island_api_client, + island_api_client=self._island_api_client, ) exploit_wrapper = ExploiterWrapper( self._telemetry_messenger, event_queue, agent_binary_repository From 7884f96a9cb4032028b9f2f32a37b73487e800c5 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 18:45:39 +0530 Subject: [PATCH 14/14] UT: Fix broken HTTPIslandAPIClient.get_agent_binary() tests --- .../island_api_client/test_http_island_api_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py index b18f3990b..22ad87161 100644 --- a/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py +++ b/monkey/tests/unit_tests/infection_monkey/island_api_client/test_http_island_api_client.py @@ -2,6 +2,7 @@ import pytest import requests import requests_mock +from common import OperatingSystem from infection_monkey.island_api_client import ( HTTPIslandAPIClient, IslandAPIConnectionError, @@ -137,7 +138,7 @@ def test_island_api_client__get_agent_binary(actual_error, expected_error): with pytest.raises(expected_error): m.get(ISLAND_GET_AGENT_BINARY_URI, exc=actual_error) - island_api_client.get_agent_binary(os_name=WINDOWS) + island_api_client.get_agent_binary(operating_system=OperatingSystem.WINDOWS) @pytest.mark.parametrize( @@ -154,4 +155,4 @@ def test_island_api_client__get_agent_binary_status_code(status_code, expected_e with pytest.raises(expected_error): m.get(ISLAND_GET_AGENT_BINARY_URI, status_code=status_code) - island_api_client.get_agent_binary(os_name=WINDOWS) + island_api_client.get_agent_binary(operating_system=OperatingSystem.WINDOWS)