diff --git a/monkey/monkey_island/cc/environment/environment_config.py b/monkey/monkey_island/cc/environment/environment_config.py index a680658a2..006f4d233 100644 --- a/monkey/monkey_island/cc/environment/environment_config.py +++ b/monkey/monkey_island/cc/environment/environment_config.py @@ -6,13 +6,11 @@ from pathlib import Path from typing import Dict, List import monkey_island.cc.environment.server_config_generator as server_config_generator -from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH +from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH from monkey_island.cc.environment.user_creds import UserCreds from monkey_island.cc.resources.auth.auth_user import User from monkey_island.cc.resources.auth.user_store import UserStore -SERVER_CONFIG_FILENAME = "server_config.json" -DEFAULT_SERVER_CONFIG_PATH = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', SERVER_CONFIG_FILENAME) class EnvironmentConfig: diff --git a/monkey/monkey_island/cc/environment/environment_singleton.py b/monkey/monkey_island/cc/environment/environment_singleton.py index aab06285f..6934c5cd2 100644 --- a/monkey/monkey_island/cc/environment/environment_singleton.py +++ b/monkey/monkey_island/cc/environment/environment_singleton.py @@ -3,7 +3,7 @@ import logging import monkey_island.cc.resources.auth.user_store as user_store from monkey_island.cc.environment import (EnvironmentConfig, aws, password, standard, testing) -from monkey_island.cc.environment.environment_config import DEFAULT_SERVER_CONFIG_PATH +from monkey_island.cc.consts import DEFAULT_SERVER_CONFIG_PATH __author__ = 'itay.mizeretz' diff --git a/monkey/monkey_island/cc/environment/test_environment_config.py b/monkey/monkey_island/cc/environment/test_environment_config.py index 2f076a3a0..d00fd1de1 100644 --- a/monkey/monkey_island/cc/environment/test_environment_config.py +++ b/monkey/monkey_island/cc/environment/test_environment_config.py @@ -1,13 +1,12 @@ import json import os -import platform from typing import Dict from unittest import TestCase from unittest.mock import MagicMock, patch import monkey_island.cc.test_common.environment.server_config_mocks as config_mocks from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH -from monkey_island.cc.environment.environment_config import EnvironmentConfig, DEFAULT_SERVER_CONFIG +from monkey_island.cc.environment.environment_config import EnvironmentConfig from monkey_island.cc.environment.user_creds import UserCreds @@ -56,13 +55,6 @@ class TestEnvironmentConfig(TestCase): self.assertDictEqual(config, json.loads(content_from_file)) - def test_default_server_config_file_path(self): - if platform.system() == "Windows": - server_file_path = MONKEY_ISLAND_ABS_PATH + r"\cc\server_config.json" - else: - server_file_path = MONKEY_ISLAND_ABS_PATH + "/cc/server_config.json" - self.assertEqual(DEFAULT_SERVER_CONFIG_PATH, server_file_path) - def test_get_from_dict(self): config_dict = config_mocks.CONFIG_WITH_CREDENTIALS env_conf = EnvironmentConfig.get_from_dict(config_dict) diff --git a/monkey/monkey_island/cc/main.py b/monkey/monkey_island/cc/main.py index 27d928134..fa7ff524d 100644 --- a/monkey/monkey_island/cc/main.py +++ b/monkey/monkey_island/cc/main.py @@ -21,7 +21,7 @@ json_setup_logging(default_path=Path(MONKEY_ISLAND_ABS_PATH, 'cc', 'island_logge logger = logging.getLogger(__name__) import monkey_island.cc.environment.environment_singleton as env_singleton # noqa: E402 -from monkey_island.cc.environment.environment_config import DEFAULT_SERVER_CONFIG_PATH +from monkey_island.cc.consts import DEFAULT_SERVER_CONFIG_PATH from common.version import get_version # noqa: E402 from monkey_island.cc.app import init_app # noqa: E402 from monkey_island.cc.server_utils.bootloader_server import BootloaderHttpServer # noqa: E402 diff --git a/monkey/monkey_island/cc/server_utils/consts.py b/monkey/monkey_island/cc/server_utils/consts.py index c302f6fb7..b5e9b7dce 100644 --- a/monkey/monkey_island/cc/server_utils/consts.py +++ b/monkey/monkey_island/cc/server_utils/consts.py @@ -4,3 +4,6 @@ __author__ = 'itay.mizeretz' MONKEY_ISLAND_ABS_PATH = os.path.join(os.getcwd(), 'monkey_island') DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS = 60 * 5 + +_SERVER_CONFIG_FILENAME = "server_config.json" +DEFAULT_SERVER_CONFIG_PATH = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', _SERVER_CONFIG_FILENAME) diff --git a/monkey/monkey_island/cc/test_consts.py b/monkey/monkey_island/cc/test_consts.py new file mode 100644 index 000000000..f1bb45805 --- /dev/null +++ b/monkey/monkey_island/cc/test_consts.py @@ -0,0 +1,11 @@ +import platform +import monkey_island.cc.consts as consts + + +def test_default_server_config_file_path(): + if platform.system() == "Windows": + server_file_path = consts.MONKEY_ISLAND_ABS_PATH + r"\cc\server_config.json" + else: + server_file_path = consts.MONKEY_ISLAND_ABS_PATH + "/cc/server_config.json" + + assert consts.DEFAULT_SERVER_CONFIG_PATH == server_file_path