From 2b6122eeb2cc4530db5a35760c34b19f019bad95 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 18 Nov 2021 13:53:11 -0500 Subject: [PATCH] Island: Move UserCreds from environment -> services/authentication --- monkey/monkey_island/cc/environment/__init__.py | 1 - .../cc/services/authentication/authentication_service.py | 2 +- .../cc/services/authentication/i_user_datastore.py | 2 +- .../cc/services/authentication/json_file_user_datastore.py | 2 +- .../cc/{environment => services/authentication}/user_creds.py | 0 .../cc/services/authentication/test_authentication_service.py | 2 +- .../{environment => services/authentication}/test_user_creds.py | 2 +- .../monkey_island/cc/services/test_json_file_user_datastore.py | 2 +- 8 files changed, 6 insertions(+), 7 deletions(-) rename monkey/monkey_island/cc/{environment => services/authentication}/user_creds.py (100%) rename monkey/tests/unit_tests/monkey_island/cc/{environment => services/authentication}/test_user_creds.py (91%) diff --git a/monkey/monkey_island/cc/environment/__init__.py b/monkey/monkey_island/cc/environment/__init__.py index 0aeac1fde..45462af7d 100644 --- a/monkey/monkey_island/cc/environment/__init__.py +++ b/monkey/monkey_island/cc/environment/__init__.py @@ -7,7 +7,6 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, ) from monkey_island.cc.environment.environment_config import EnvironmentConfig -from monkey_island.cc.environment.user_creds import UserCreds logger = logging.getLogger(__name__) diff --git a/monkey/monkey_island/cc/services/authentication/authentication_service.py b/monkey/monkey_island/cc/services/authentication/authentication_service.py index ec191d04e..f164bde1e 100644 --- a/monkey/monkey_island/cc/services/authentication/authentication_service.py +++ b/monkey/monkey_island/cc/services/authentication/authentication_service.py @@ -1,7 +1,6 @@ import bcrypt from common.utils.exceptions import IncorrectCredentialsError, UnknownUserError -from monkey_island.cc.environment.user_creds import UserCreds from monkey_island.cc.server_utils.encryption import ( reset_datastore_encryptor, unlock_datastore_encryptor, @@ -9,6 +8,7 @@ from monkey_island.cc.server_utils.encryption import ( from monkey_island.cc.setup.mongo.database_initializer import reset_database from .i_user_datastore import IUserDatastore +from .user_creds import UserCreds class AuthenticationService: diff --git a/monkey/monkey_island/cc/services/authentication/i_user_datastore.py b/monkey/monkey_island/cc/services/authentication/i_user_datastore.py index 13331963a..38e93922e 100644 --- a/monkey/monkey_island/cc/services/authentication/i_user_datastore.py +++ b/monkey/monkey_island/cc/services/authentication/i_user_datastore.py @@ -1,6 +1,6 @@ import abc -from monkey_island.cc.environment.user_creds import UserCreds +from .user_creds import UserCreds class IUserDatastore(metaclass=abc.ABCMeta): diff --git a/monkey/monkey_island/cc/services/authentication/json_file_user_datastore.py b/monkey/monkey_island/cc/services/authentication/json_file_user_datastore.py index 7420fe1dc..ff66a7c9b 100644 --- a/monkey/monkey_island/cc/services/authentication/json_file_user_datastore.py +++ b/monkey/monkey_island/cc/services/authentication/json_file_user_datastore.py @@ -6,10 +6,10 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) -from monkey_island.cc.environment.user_creds import UserCreds from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file from .i_user_datastore import IUserDatastore +from .user_creds import UserCreds CREDENTIALS_FILE = "credentials.json" diff --git a/monkey/monkey_island/cc/environment/user_creds.py b/monkey/monkey_island/cc/services/authentication/user_creds.py similarity index 100% rename from monkey/monkey_island/cc/environment/user_creds.py rename to monkey/monkey_island/cc/services/authentication/user_creds.py diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py index 0cb8b1d45..491845865 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_authentication_service.py @@ -8,10 +8,10 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) -from monkey_island.cc.environment.user_creds import UserCreds from monkey_island.cc.services import AuthenticationService from monkey_island.cc.services.authentication import authentication_service from monkey_island.cc.services.authentication.i_user_datastore import IUserDatastore +from monkey_island.cc.services.authentication.user_creds import UserCreds USERNAME = "user1" PASSWORD = "test" diff --git a/monkey/tests/unit_tests/monkey_island/cc/environment/test_user_creds.py b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py similarity index 91% rename from monkey/tests/unit_tests/monkey_island/cc/environment/test_user_creds.py rename to monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py index d629687d6..0bd9f6421 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/environment/test_user_creds.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py @@ -1,4 +1,4 @@ -from monkey_island.cc.environment.user_creds import UserCreds +from monkey_island.cc.services.authentication.user_creds import UserCreds TEST_USER = "Test" TEST_HASH = "abc1231234" diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_json_file_user_datastore.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_json_file_user_datastore.py index fef7b4f20..4aae5cd3d 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_json_file_user_datastore.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_json_file_user_datastore.py @@ -9,12 +9,12 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) -from monkey_island.cc.environment.user_creds import UserCreds from monkey_island.cc.server_utils.file_utils import is_windows_os from monkey_island.cc.services.authentication.json_file_user_datastore import ( CREDENTIALS_FILE, JsonFileUserDatastore, ) +from monkey_island.cc.services.authentication.user_creds import UserCreds USERNAME = "test" PASSWORD_HASH = "DEADBEEF"