forked from p15670423/monkey
cc: fix server_config_generator behavior
This commit is contained in:
parent
986219bd86
commit
4b5415ac0b
|
@ -1,7 +1,8 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from monkey_island.cc.consts import DEFAULT_STANDARD_SERVER_CONFIG
|
||||||
|
|
||||||
|
|
||||||
def create_default_config_file(path):
|
def create_default_config_file(path):
|
||||||
default_config_path = f"{path}.default"
|
default_config = Path(DEFAULT_STANDARD_SERVER_CONFIG).read_text()
|
||||||
default_config = Path(default_config_path).read_text()
|
|
||||||
Path(path).write_text(default_config)
|
Path(path).write_text(default_config)
|
||||||
|
|
|
@ -121,3 +121,15 @@ def test_get_users():
|
||||||
assert users[0].id == 1
|
assert users[0].id == 1
|
||||||
assert users[0].username == user
|
assert users[0].username == user
|
||||||
assert users[0].secret == password_hash
|
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
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"server_config": "password",
|
||||||
|
"deployment": "standard"
|
||||||
|
}
|
|
@ -7,3 +7,6 @@ DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS = 60 * 5
|
||||||
|
|
||||||
_SERVER_CONFIG_FILENAME = "server_config.json"
|
_SERVER_CONFIG_FILENAME = "server_config.json"
|
||||||
DEFAULT_SERVER_CONFIG_PATH = os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', _SERVER_CONFIG_FILENAME)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue