From e25eb194a1a00b117384a931e124edc28ce446f0 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 22 Jun 2022 08:41:11 -0700 Subject: [PATCH] UT: Remove `supported_os` for exploiters from all tests --- .../tests/common/example_agent_configuration.py | 4 +--- .../monkey_configs/automated_master_config.json | 16 ++++++++-------- .../common/test_agent_configuration.py | 7 +------ .../infection_monkey/master/test_exploiter.py | 8 ++++---- .../monkey_island/cc/services/test_config.py | 11 ++--------- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/monkey/tests/common/example_agent_configuration.py b/monkey/tests/common/example_agent_configuration.py index 640771df4..25a1dbd5e 100644 --- a/monkey/tests/common/example_agent_configuration.py +++ b/monkey/tests/common/example_agent_configuration.py @@ -39,18 +39,16 @@ NETWORK_SCAN_CONFIGURATION = { } BRUTE_FORCE = [ - {"name": "ex1", "options": {}, "supported_os": ["LINUX"]}, + {"name": "ex1", "options": {}}, { "name": "ex2", "options": {"smb_download_timeout": 10}, - "supported_os": ["LINUX", "WINDOWS"], }, ] VULNERABILITY = [ { "name": "ex3", "options": {"smb_download_timeout": 10}, - "supported_os": ["WINDOWS"], }, ] EXPLOITATION_CONFIGURATION = { diff --git a/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json b/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json index 7fcc2285d..c0c035b9d 100644 --- a/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json +++ b/monkey/tests/data_for_tests/monkey_configs/automated_master_config.json @@ -47,16 +47,16 @@ "exploiters": { "options": {}, "brute_force": [ - {"name": "MSSQLExploiter", "supported_os": ["windows"], "options": {}}, - {"name": "PowerShellExploiter", "supported_os": ["windows"], "options": {}}, - {"name": "SmbExploiter", "supported_os": ["windows"], "options": {}}, - {"name": "SSHExploiter", "supported_os": ["linux"], "options": {}}, - {"name": "WmiExploiter", "supported_os": ["windows"], "options": {}} + {"name": "MSSQLExploiter", "options": {}}, + {"name": "PowerShellExploiter", "options": {}}, + {"name": "SmbExploiter", "options": {}}, + {"name": "SSHExploiter", "options": {}}, + {"name": "WmiExploiter", "options": {}} ], "vulnerability": [ - {"name": "HadoopExploiter", "supported_os": ["linux", "windows"], "options": {}}, - {"name": "ShellShockExploiter", "supported_os": ["linux"], "options": {}}, - {"name": "ZerologonExploiter", "supported_os": ["windows"], "options": {}} + {"name": "HadoopExploiter", "options": {}}, + {"name": "ShellShockExploiter", "options": {}}, + {"name": "ZerologonExploiter", "options": {}} ] } }, diff --git a/monkey/tests/unit_tests/common/test_agent_configuration.py b/monkey/tests/unit_tests/common/test_agent_configuration.py index 3383ab1b7..7ea80cfc5 100644 --- a/monkey/tests/unit_tests/common/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/test_agent_configuration.py @@ -23,7 +23,6 @@ from tests.common.example_agent_configuration import ( WINDOWS_FILENAME, ) -from common import OperatingSystems from common.configuration import ( DEFAULT_AGENT_CONFIGURATION_JSON, AgentConfiguration, @@ -126,16 +125,12 @@ def test_exploitation_options_configuration_schema(): def test_exploiter_configuration_schema(): name = "bond" options = {"gun": "Walther PPK", "car": "Aston Martin DB5"} - supported_os = [OperatingSystems.LINUX, OperatingSystems.WINDOWS] schema = ExploiterConfigurationSchema() - config = schema.load( - {"name": name, "options": options, "supported_os": [os_.name for os_ in supported_os]} - ) + config = schema.load({"name": name, "options": options}) assert config.name == name assert config.options == options - assert config.supported_os == supported_os def test_exploitation_configuration(): diff --git a/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py b/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py index 3c76c903f..42b64821f 100644 --- a/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py +++ b/monkey/tests/unit_tests/infection_monkey/master/test_exploiter.py @@ -38,12 +38,12 @@ def exploiter_config(): return { "options": {"dropper_path_linux": "/tmp/monkey"}, "brute_force": [ - {"name": "HadoopExploiter", "supported_os": ["windows"], "options": {"timeout": 10}}, - {"name": "SSHExploiter", "supported_os": ["linux"], "options": {}}, - {"name": "WmiExploiter", "supported_os": ["windows"], "options": {"timeout": 10}}, + {"name": "HadoopExploiter", "options": {"timeout": 10}}, + {"name": "SSHExploiter", "options": {}}, + {"name": "WmiExploiter", "options": {"timeout": 10}}, ], "vulnerability": [ - {"name": "ZerologonExploiter", "supported_os": ["windows"], "options": {}}, + {"name": "ZerologonExploiter", "options": {}}, ], } diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py index df866e388..85f3f4823 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py @@ -1,6 +1,5 @@ import pytest -from common import OperatingSystems from monkey_island.cc.services.config import ConfigService # If tests fail because config path is changed, sync with @@ -172,38 +171,32 @@ def test_format_config_for_agent__exploiters(): "http_ports": [80, 443, 7001, 8008, 8080, 9200], }, "brute_force": [ - {"name": "MSSQLExploiter", "supported_os": [OperatingSystems.WINDOWS], "options": {}}, + {"name": "MSSQLExploiter", "options": {}}, { "name": "PowerShellExploiter", - "supported_os": [OperatingSystems.WINDOWS], "options": {}, }, - {"name": "SSHExploiter", "supported_os": [OperatingSystems.LINUX], "options": {}}, + {"name": "SSHExploiter", "options": {}}, { "name": "SmbExploiter", - "supported_os": [OperatingSystems.WINDOWS], "options": {"smb_download_timeout": 30}, }, { "name": "WmiExploiter", - "supported_os": [OperatingSystems.WINDOWS], "options": {"smb_download_timeout": 30}, }, ], "vulnerability": [ { "name": "HadoopExploiter", - "supported_os": [OperatingSystems.LINUX, OperatingSystems.WINDOWS], "options": {}, }, { "name": "Log4ShellExploiter", - "supported_os": [OperatingSystems.LINUX, OperatingSystems.WINDOWS], "options": {}, }, { "name": "ZerologonExploiter", - "supported_os": [OperatingSystems.WINDOWS], "options": {}, }, ],