diff --git a/monkey/monkey_island.py b/monkey/monkey_island.py index 2e410cd9f..f27efa01a 100644 --- a/monkey/monkey_island.py +++ b/monkey/monkey_island.py @@ -2,8 +2,8 @@ from gevent import monkey as gevent_monkey gevent_monkey.patch_all() -from monkey_island.cc.main import main -from monkey_island.cc.environment.environment_config import DEFAULT_SERVER_CONFIG_PATH +from monkey_island.cc.main import main # noqa: E402 +from monkey_island.cc.environment.environment_config import DEFAULT_SERVER_CONFIG_PATH # noqa: E402 def parse_cli_args(): diff --git a/monkey/monkey_island/cc/environment/environment_singleton.py b/monkey/monkey_island/cc/environment/environment_singleton.py index 1d037051d..accb104ce 100644 --- a/monkey/monkey_island/cc/environment/environment_singleton.py +++ b/monkey/monkey_island/cc/environment/environment_singleton.py @@ -37,6 +37,7 @@ def set_to_standard(): env.save_config() user_store.UserStore.set_users(env.get_auth_users()) + def initialize_from_file(file_path): try: config = EnvironmentConfig(file_path) @@ -49,4 +50,5 @@ def initialize_from_file(file_path): logger.error('Failed initializing environment', exc_info=True) raise + initialize_from_file(DEFAULT_SERVER_CONFIG_PATH) diff --git a/monkey/monkey_island/cc/environment/test__init__.py b/monkey/monkey_island/cc/environment/test__init__.py index 3e805b712..fde0a8b27 100644 --- a/monkey/monkey_island/cc/environment/test__init__.py +++ b/monkey/monkey_island/cc/environment/test__init__.py @@ -1,4 +1,3 @@ -import json import os import tempfile from typing import Dict @@ -6,10 +5,12 @@ from unittest import TestCase from unittest.mock import MagicMock, patch from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH -from common.utils.exceptions import (AlreadyRegisteredError, CredentialsNotRequiredError, - InvalidRegistrationCredentialsError, RegistrationNotNeededError) -from monkey_island.cc.environment import Environment, EnvironmentConfig, UserCreds - +from common.utils.exceptions import (AlreadyRegisteredError, + CredentialsNotRequiredError, + InvalidRegistrationCredentialsError, + RegistrationNotNeededError) +from monkey_island.cc.environment import (Environment, EnvironmentConfig, + UserCreds) TEST_RESOURCES_DIR = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "testing", "environment") @@ -19,7 +20,7 @@ PARTIAL_CREDENTIALS = os.path.join(TEST_RESOURCES_DIR, "server_config_partial_cr STANDARD_WITH_CREDENTIALS = os.path.join(TEST_RESOURCES_DIR, "server_config_standard_with_credentials.json") STANDARD_ENV = os.path.join(TEST_RESOURCES_DIR, - "server_config_standard_env.json") + "server_config_standard_env.json") def get_tmp_file(): diff --git a/monkey/monkey_island/cc/main.py b/monkey/monkey_island/cc/main.py index b60a61497..3da752ec9 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.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH +from monkey_island.cc.server_utils.consts import DEFAULT_SERVER_CONFIG_PATH # noqa: E402 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