cc: fix server_config_generator behavior

This commit is contained in:
Mike Salvatore 2021-02-08 15:00:46 -05:00
parent 986219bd86
commit 4b5415ac0b
4 changed files with 22 additions and 2 deletions

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,4 @@
{
"server_config": "password",
"deployment": "standard"
}

View File

@ -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)