diff --git a/monkey/monkey_island/cc/environment/server_config_generator.py b/monkey/monkey_island/cc/environment/server_config_generator.py index d5c645564..d52d5261d 100644 --- a/monkey/monkey_island/cc/environment/server_config_generator.py +++ b/monkey/monkey_island/cc/environment/server_config_generator.py @@ -1,7 +1,8 @@ from pathlib import Path +from monkey_island.cc.consts import DEFAULT_STANDARD_SERVER_CONFIG + def create_default_config_file(path): - default_config_path = f"{path}.default" - default_config = Path(default_config_path).read_text() + default_config = Path(DEFAULT_STANDARD_SERVER_CONFIG).read_text() Path(path).write_text(default_config) diff --git a/monkey/monkey_island/cc/environment/test_environment_config.py b/monkey/monkey_island/cc/environment/test_environment_config.py index dea22dd3f..f038eed74 100644 --- a/monkey/monkey_island/cc/environment/test_environment_config.py +++ b/monkey/monkey_island/cc/environment/test_environment_config.py @@ -121,3 +121,15 @@ def test_get_users(): assert users[0].id == 1 assert users[0].username == user assert users[0].secret == password_hash + +def test_generate_default_file(config_file): + environment_config = EnvironmentConfig.get_from_file(config_file) + + assert os.path.isfile(config_file) + + assert environment_config.server_config == "password" + assert environment_config.deployment == "standard" + assert environment_config.user_creds.username == "" + assert environment_config.user_creds.password_hash == "" + assert environment_config.aws is None + environment_config.server_config_path == config_file diff --git a/monkey/monkey_island/cc/server_config.json.standard b/monkey/monkey_island/cc/server_config.json.standard new file mode 100644 index 000000000..7bdd9a163 --- /dev/null +++ b/monkey/monkey_island/cc/server_config.json.standard @@ -0,0 +1,4 @@ +{ + "server_config": "password", + "deployment": "standard" +} diff --git a/monkey/monkey_island/cc/server_utils/consts.py b/monkey/monkey_island/cc/server_utils/consts.py index b5e9b7dce..0be7e776d 100644 --- a/monkey/monkey_island/cc/server_utils/consts.py +++ b/monkey/monkey_island/cc/server_utils/consts.py @@ -7,3 +7,6 @@ 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) + +_STANDARD_SERVER_CONFIG_FILENAME = "server_config.json.standard" +DEFAULT_STANDARD_SERVER_CONFIG = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', _STANDARD_SERVER_CONFIG_FILENAME)