From 03566d2966b9d76b45d650f9607f1a043993d135 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 30 Nov 2021 10:52:28 +0200 Subject: [PATCH] Island: remove the server config extraction from server_config.json in island's cwd All deployments can be configured via command line OR by modifying the server_config.json that comes with the deployment --- monkey/monkey_island/cc/setup/config_setup.py | 4 --- .../cc/setup/test_server_setup.py | 26 ------------------- 2 files changed, 30 deletions(-) diff --git a/monkey/monkey_island/cc/setup/config_setup.py b/monkey/monkey_island/cc/setup/config_setup.py index c38ee791b..c362feb82 100644 --- a/monkey/monkey_island/cc/setup/config_setup.py +++ b/monkey/monkey_island/cc/setup/config_setup.py @@ -1,5 +1,4 @@ import json -import os from logging import getLogger from pathlib import Path @@ -11,7 +10,6 @@ from monkey_island.cc.setup.island_config_options import IslandConfigOptions logger = getLogger(__name__) PACKAGE_CONFIG_PATH = Path(MONKEY_ISLAND_ABS_PATH, "cc", SERVER_CONFIG_FILENAME) -USER_CONFIG_PATH = Path(os.getcwd(), SERVER_CONFIG_FILENAME) def get_server_config(island_args: IslandCmdArgs) -> IslandConfigOptions: @@ -19,8 +17,6 @@ def get_server_config(island_args: IslandCmdArgs) -> IslandConfigOptions: _update_config_from_file(config, PACKAGE_CONFIG_PATH) - _update_config_from_file(config, USER_CONFIG_PATH) - if island_args.server_config_path: path_to_config = expand_path(island_args.server_config_path) _update_config_from_file(config, path_to_config) diff --git a/monkey/tests/unit_tests/monkey_island/cc/setup/test_server_setup.py b/monkey/tests/unit_tests/monkey_island/cc/setup/test_server_setup.py index 7517aa665..a6f4c59ca 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/setup/test_server_setup.py +++ b/monkey/tests/unit_tests/monkey_island/cc/setup/test_server_setup.py @@ -17,12 +17,6 @@ def cmd_server_config_path(tmpdir) -> Path: return tmpdir / "fake_server_config.json" -@pytest.fixture -def user_default_server_config_path(tmpdir) -> Path: - # Represents the config that can be put into the install dir - return tmpdir / "fake_server_config2.json" - - @pytest.fixture def deployment_server_config_path(tmpdir) -> Path: # Represents the config that is built in, deployment specific @@ -42,14 +36,6 @@ def mock_deployment_config_path(monkeypatch, deployment_server_config_path): ) -@pytest.fixture(autouse=True) -def mock_user_config_path(monkeypatch, user_default_server_config_path): - monkeypatch.setattr( - "monkey_island.cc.setup.config_setup.USER_CONFIG_PATH", - user_default_server_config_path, - ) - - def test_extract_config_defaults(): expected = IslandConfigOptions({}) assert ( @@ -67,18 +53,6 @@ def test_deployment_config_overrides_defaults(deployment_server_config_path): ) -def test_user_config_overrides_deployment( - deployment_server_config_path, cmd_server_config_path, user_default_server_config_path -): - expected = IslandConfigOptions({"log_level": "/log_level_3"}) - create_server_config(dumps({"log_level": "/log_level_2"}), deployment_server_config_path) - create_server_config(dumps({"log_level": "/log_level_3"}), user_default_server_config_path) - extracted_config = _extract_config( - IslandCmdArgs(setup_only=False, server_config_path=cmd_server_config_path) - ) - assert expected.__dict__ == extracted_config.__dict__ - - def test_cmd_config_overrides_everything( deployment_server_config_path, cmd_server_config_path, user_default_server_config_path ):