forked from p15670423/monkey
Island: remove the server config extraction from server_config.json in island's cwd
All deployments can be configured via command line OR by modifying the server_config.json that comes with the deployment
This commit is contained in:
parent
e95df875be
commit
03566d2966
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
import os
|
||||
from logging import getLogger
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -11,7 +10,6 @@ from monkey_island.cc.setup.island_config_options import IslandConfigOptions
|
|||
logger = getLogger(__name__)
|
||||
|
||||
PACKAGE_CONFIG_PATH = Path(MONKEY_ISLAND_ABS_PATH, "cc", SERVER_CONFIG_FILENAME)
|
||||
USER_CONFIG_PATH = Path(os.getcwd(), SERVER_CONFIG_FILENAME)
|
||||
|
||||
|
||||
def get_server_config(island_args: IslandCmdArgs) -> IslandConfigOptions:
|
||||
|
@ -19,8 +17,6 @@ def get_server_config(island_args: IslandCmdArgs) -> IslandConfigOptions:
|
|||
|
||||
_update_config_from_file(config, PACKAGE_CONFIG_PATH)
|
||||
|
||||
_update_config_from_file(config, USER_CONFIG_PATH)
|
||||
|
||||
if island_args.server_config_path:
|
||||
path_to_config = expand_path(island_args.server_config_path)
|
||||
_update_config_from_file(config, path_to_config)
|
||||
|
|
|
@ -17,12 +17,6 @@ def cmd_server_config_path(tmpdir) -> Path:
|
|||
return tmpdir / "fake_server_config.json"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_default_server_config_path(tmpdir) -> Path:
|
||||
# Represents the config that can be put into the install dir
|
||||
return tmpdir / "fake_server_config2.json"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deployment_server_config_path(tmpdir) -> Path:
|
||||
# Represents the config that is built in, deployment specific
|
||||
|
@ -42,14 +36,6 @@ def mock_deployment_config_path(monkeypatch, deployment_server_config_path):
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_user_config_path(monkeypatch, user_default_server_config_path):
|
||||
monkeypatch.setattr(
|
||||
"monkey_island.cc.setup.config_setup.USER_CONFIG_PATH",
|
||||
user_default_server_config_path,
|
||||
)
|
||||
|
||||
|
||||
def test_extract_config_defaults():
|
||||
expected = IslandConfigOptions({})
|
||||
assert (
|
||||
|
@ -67,18 +53,6 @@ def test_deployment_config_overrides_defaults(deployment_server_config_path):
|
|||
)
|
||||
|
||||
|
||||
def test_user_config_overrides_deployment(
|
||||
deployment_server_config_path, cmd_server_config_path, user_default_server_config_path
|
||||
):
|
||||
expected = IslandConfigOptions({"log_level": "/log_level_3"})
|
||||
create_server_config(dumps({"log_level": "/log_level_2"}), deployment_server_config_path)
|
||||
create_server_config(dumps({"log_level": "/log_level_3"}), user_default_server_config_path)
|
||||
extracted_config = _extract_config(
|
||||
IslandCmdArgs(setup_only=False, server_config_path=cmd_server_config_path)
|
||||
)
|
||||
assert expected.__dict__ == extracted_config.__dict__
|
||||
|
||||
|
||||
def test_cmd_config_overrides_everything(
|
||||
deployment_server_config_path, cmd_server_config_path, user_default_server_config_path
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue