From 04feb1b31d921e1d59dc40d27d63b6e07e7554f8 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 29 Nov 2021 15:09:20 +0200 Subject: [PATCH] Island,UT: move PACKAGE_CONFIG_PATH and USER_CONFIG_PATH consts to config_setup.py, where they are used --- monkey/monkey_island/cc/server_utils/consts.py | 3 --- monkey/monkey_island/cc/setup/config_setup.py | 6 +++++- .../monkey_island/cc/server_utils/test_consts.py | 10 ---------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/monkey/monkey_island/cc/server_utils/consts.py b/monkey/monkey_island/cc/server_utils/consts.py index f5cff557c..29fe78933 100644 --- a/monkey/monkey_island/cc/server_utils/consts.py +++ b/monkey/monkey_island/cc/server_utils/consts.py @@ -36,9 +36,6 @@ MONGO_EXECUTABLE_PATH = ( ) MONGO_CONNECTION_TIMEOUT = 15 -PACKAGE_CONFIG_PATH = Path(MONKEY_ISLAND_ABS_PATH, "cc", SERVER_CONFIG_FILENAME) -USER_CONFIG_PATH = Path(os.getcwd(), SERVER_CONFIG_FILENAME) - DEFAULT_LOG_LEVEL = "INFO" DEFAULT_START_MONGO_DB = True diff --git a/monkey/monkey_island/cc/setup/config_setup.py b/monkey/monkey_island/cc/setup/config_setup.py index dee694b68..3dca8e3dc 100644 --- a/monkey/monkey_island/cc/setup/config_setup.py +++ b/monkey/monkey_island/cc/setup/config_setup.py @@ -1,14 +1,18 @@ import json +import os from logging import getLogger from pathlib import Path from common.utils.file_utils import expand_path from monkey_island.cc.arg_parser import IslandCmdArgs -from monkey_island.cc.server_utils.consts import PACKAGE_CONFIG_PATH, USER_CONFIG_PATH +from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH, SERVER_CONFIG_FILENAME 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: config = IslandConfigOptions() diff --git a/monkey/tests/unit_tests/monkey_island/cc/server_utils/test_consts.py b/monkey/tests/unit_tests/monkey_island/cc/server_utils/test_consts.py index 996226e0d..8d0b0b1b4 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/server_utils/test_consts.py +++ b/monkey/tests/unit_tests/monkey_island/cc/server_utils/test_consts.py @@ -1,5 +1,4 @@ import os -import platform from monkey_island.cc.server_utils import consts @@ -7,12 +6,3 @@ from monkey_island.cc.server_utils import consts def test_monkey_island_abs_path(): assert consts.MONKEY_ISLAND_ABS_PATH.endswith("monkey_island") assert os.path.isdir(consts.MONKEY_ISLAND_ABS_PATH) - - -def test_default_server_config_file_path(): - if platform.system() == "Windows": - server_file_path = f"{consts.MONKEY_ISLAND_ABS_PATH}\\cc\\{consts.SERVER_CONFIG_FILENAME}" - else: - server_file_path = f"{consts.MONKEY_ISLAND_ABS_PATH}/cc/{consts.SERVER_CONFIG_FILENAME}" - - assert consts.PACKAGE_CONFIG_PATH == server_file_path