diff --git a/monkey/tests/data_for_tests/server_configs/server_config_standard_env.json b/monkey/tests/data_for_tests/server_configs/server_config_standard_env.json deleted file mode 100644 index 9c3a9899f..000000000 --- a/monkey/tests/data_for_tests/server_configs/server_config_standard_env.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "environment" : { - "server_config": "standard", - "deployment": "develop" - }, - "mongodb": { - "start_mongodb": true - } -} diff --git a/monkey/tests/data_for_tests/server_configs/server_config_standard_with_credentials.json b/monkey/tests/data_for_tests/server_configs/server_config_standard_with_credentials.json deleted file mode 100644 index 28d8653c8..000000000 --- a/monkey/tests/data_for_tests/server_configs/server_config_standard_with_credentials.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "log_level": "NOTICE", - "environment" : { - "server_config": "standard", - "deployment": "develop", - "user": "test", - "password_hash": "abcdef" - }, - "mongodb": { - "start_mongodb": true - } -} diff --git a/monkey/tests/data_for_tests/server_configs/server_config_with_credentials.json b/monkey/tests/data_for_tests/server_configs/server_config_with_credentials.json index 2f75c48fb..8690ef1c7 100644 --- a/monkey/tests/data_for_tests/server_configs/server_config_with_credentials.json +++ b/monkey/tests/data_for_tests/server_configs/server_config_with_credentials.json @@ -1,4 +1,5 @@ { + "log_level": "NOTICE", "environment" : { "server_config": "password", "deployment": "develop", diff --git a/monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py b/monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py index 767f765d9..c5d7b46b7 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py +++ b/monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py @@ -16,8 +16,3 @@ def no_credentials(server_configs_dir): @pytest.fixture(scope="module") def partial_credentials(server_configs_dir): return os.path.join(server_configs_dir, "server_config_partial_credentials.json") - - -@pytest.fixture(scope="module") -def standard_with_credentials(server_configs_dir): - return os.path.join(server_configs_dir, "server_config_standard_with_credentials.json") diff --git a/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py index 030f99169..10adea8b7 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py +++ b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py @@ -17,8 +17,6 @@ from monkey_island.cc.environment import Environment, EnvironmentConfig, UserCre WITH_CREDENTIALS = None NO_CREDENTIALS = None PARTIAL_CREDENTIALS = None -STANDARD_WITH_CREDENTIALS = None -STANDARD_ENV = None EMPTY_USER_CREDENTIALS = UserCreds("", "") FULL_USER_CREDENTIALS = UserCreds(username="test", password_hash="1231234") @@ -31,16 +29,10 @@ def configure_resources(server_configs_dir): global WITH_CREDENTIALS global NO_CREDENTIALS global PARTIAL_CREDENTIALS - global STANDARD_WITH_CREDENTIALS - global STANDARD_ENV WITH_CREDENTIALS = os.path.join(server_configs_dir, "server_config_with_credentials.json") NO_CREDENTIALS = os.path.join(server_configs_dir, "server_config_no_credentials.json") PARTIAL_CREDENTIALS = os.path.join(server_configs_dir, "server_config_partial_credentials.json") - STANDARD_WITH_CREDENTIALS = os.path.join( - server_configs_dir, "server_config_standard_with_credentials.json" - ) - STANDARD_ENV = os.path.join(server_configs_dir, "server_config_standard_env.json") def get_tmp_file(): @@ -123,29 +115,18 @@ class TestEnvironment(TestCase): self._test_bool_env_method("needs_registration", env, NO_CREDENTIALS, True) self._test_bool_env_method("needs_registration", env, PARTIAL_CREDENTIALS, True) - env = TestEnvironment.EnvironmentCredentialsNotRequired() - self._test_bool_env_method("needs_registration", env, STANDARD_ENV, False) - self._test_bool_env_method("needs_registration", env, STANDARD_WITH_CREDENTIALS, False) - def test_is_registered(self): env = TestEnvironment.EnvironmentCredentialsRequired() self._test_bool_env_method("_is_registered", env, WITH_CREDENTIALS, True) self._test_bool_env_method("_is_registered", env, NO_CREDENTIALS, False) self._test_bool_env_method("_is_registered", env, PARTIAL_CREDENTIALS, False) - env = TestEnvironment.EnvironmentCredentialsNotRequired() - self._test_bool_env_method("_is_registered", env, STANDARD_ENV, False) - self._test_bool_env_method("_is_registered", env, STANDARD_WITH_CREDENTIALS, False) - def test_is_credentials_set_up(self): env = TestEnvironment.EnvironmentCredentialsRequired() self._test_bool_env_method("_is_credentials_set_up", env, NO_CREDENTIALS, False) self._test_bool_env_method("_is_credentials_set_up", env, WITH_CREDENTIALS, True) self._test_bool_env_method("_is_credentials_set_up", env, PARTIAL_CREDENTIALS, False) - env = TestEnvironment.EnvironmentCredentialsNotRequired() - self._test_bool_env_method("_is_credentials_set_up", env, STANDARD_ENV, False) - def _test_bool_env_method( self, method_name: str, env: Environment, config: Dict, expected_result: bool ): diff --git a/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py index 0e3efda04..52f0d96ca 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py +++ b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py @@ -40,8 +40,8 @@ def test_get_with_partial_credentials(partial_credentials): assert config_dict["user"] == "test" -def test_save_to_file(config_file, standard_with_credentials): - shutil.copyfile(standard_with_credentials, config_file) +def test_save_to_file(config_file, with_credentials): + shutil.copyfile(with_credentials, config_file) environment_config = EnvironmentConfig(config_file) environment_config.aws = "test_aws" @@ -53,8 +53,8 @@ def test_save_to_file(config_file, standard_with_credentials): assert environment_config.to_dict() == from_file["environment"] -def test_save_to_file_preserve_log_level(config_file, standard_with_credentials): - shutil.copyfile(standard_with_credentials, config_file) +def test_save_to_file_preserve_log_level(config_file, with_credentials): + shutil.copyfile(with_credentials, config_file) environment_config = EnvironmentConfig(config_file) environment_config.aws = "test_aws" @@ -67,12 +67,12 @@ def test_save_to_file_preserve_log_level(config_file, standard_with_credentials) assert from_file["log_level"] == "NOTICE" -def test_add_user(config_file, standard_with_credentials): +def test_add_user(config_file, with_credentials): new_user = "new_user" new_password_hash = "fedcba" new_user_creds = UserCreds(new_user, new_password_hash) - shutil.copyfile(standard_with_credentials, config_file) + shutil.copyfile(with_credentials, config_file) environment_config = EnvironmentConfig(config_file) environment_config.add_user(new_user_creds) @@ -85,8 +85,8 @@ def test_add_user(config_file, standard_with_credentials): assert from_file["environment"]["password_hash"] == new_password_hash -def test_get_users(standard_with_credentials): - environment_config = EnvironmentConfig(standard_with_credentials) +def test_get_users(with_credentials): + environment_config = EnvironmentConfig(with_credentials) users = environment_config.get_users() assert len(users) == 1