From 8608b05c465a46b2c0d8d0371ed5fe596606a9b5 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 12 Jul 2022 08:53:56 -0400 Subject: [PATCH] Island: Move UserCreds to models package --- monkey/monkey_island/cc/models/__init__.py | 1 + .../user_creds.py => models/user_credentials.py} | 0 monkey/monkey_island/cc/repository/i_user_repository.py | 2 +- .../cc/services/authentication/authentication_service.py | 3 +-- .../cc/services/authentication/json_file_user_datastore.py | 3 +-- .../test_user_creds.py => models/test_user_credentials.py} | 2 +- .../monkey_island/cc/services/test_authentication_service.py | 2 +- .../monkey_island/cc/services/test_json_file_user_datastore.py | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) rename monkey/monkey_island/cc/{services/authentication/user_creds.py => models/user_credentials.py} (100%) rename monkey/tests/unit_tests/monkey_island/cc/{services/authentication/test_user_creds.py => models/test_user_credentials.py} (91%) diff --git a/monkey/monkey_island/cc/models/__init__.py b/monkey/monkey_island/cc/models/__init__.py index bf2addf63..3ce8893de 100644 --- a/monkey/monkey_island/cc/models/__init__.py +++ b/monkey/monkey_island/cc/models/__init__.py @@ -9,3 +9,4 @@ from .pba_results import PbaResults from monkey_island.cc.models.report.report import Report from .stolen_credentials import StolenCredentials from .simulation import Simulation, SimulationSchema, IslandMode +from .user_credentials import UserCreds diff --git a/monkey/monkey_island/cc/services/authentication/user_creds.py b/monkey/monkey_island/cc/models/user_credentials.py similarity index 100% rename from monkey/monkey_island/cc/services/authentication/user_creds.py rename to monkey/monkey_island/cc/models/user_credentials.py diff --git a/monkey/monkey_island/cc/repository/i_user_repository.py b/monkey/monkey_island/cc/repository/i_user_repository.py index ee0e17f0a..1e5e7f0fd 100644 --- a/monkey/monkey_island/cc/repository/i_user_repository.py +++ b/monkey/monkey_island/cc/repository/i_user_repository.py @@ -1,6 +1,6 @@ import abc -from monkey_island.cc.services.authentication.user_creds import UserCreds +from monkey_island.cc.models import UserCreds class IUserRepository(metaclass=abc.ABCMeta): diff --git a/monkey/monkey_island/cc/services/authentication/authentication_service.py b/monkey/monkey_island/cc/services/authentication/authentication_service.py index d8f445115..8e5402be3 100644 --- a/monkey/monkey_island/cc/services/authentication/authentication_service.py +++ b/monkey/monkey_island/cc/services/authentication/authentication_service.py @@ -7,6 +7,7 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) +from monkey_island.cc.models import UserCreds from monkey_island.cc.repository import IUserRepository from monkey_island.cc.server_utils.encryption import ( reset_datastore_encryptor, @@ -14,8 +15,6 @@ from monkey_island.cc.server_utils.encryption import ( ) from monkey_island.cc.setup.mongo.database_initializer import reset_database -from .user_creds import UserCreds - class AuthenticationService: def __init__(self, data_dir: Path, user_datastore: IUserRepository): 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 a75310733..3d9f0d45c 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,11 +6,10 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) +from monkey_island.cc.models import UserCreds from monkey_island.cc.repository import IUserRepository from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file -from .user_creds import UserCreds - CREDENTIALS_FILE = "credentials.json" diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py b/monkey/tests/unit_tests/monkey_island/cc/models/test_user_credentials.py similarity index 91% rename from monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py rename to monkey/tests/unit_tests/monkey_island/cc/models/test_user_credentials.py index 0bd9f6421..f294e2364 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/authentication/test_user_creds.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/test_user_credentials.py @@ -1,4 +1,4 @@ -from monkey_island.cc.services.authentication.user_creds import UserCreds +from monkey_island.cc.models import UserCreds TEST_USER = "Test" TEST_HASH = "abc1231234" diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_authentication_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_authentication_service.py index 6aa3dfbbd..eac6f646c 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_authentication_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_authentication_service.py @@ -8,10 +8,10 @@ from common.utils.exceptions import ( InvalidRegistrationCredentialsError, UnknownUserError, ) +from monkey_island.cc.models import UserCreds from monkey_island.cc.repository import IUserRepository from monkey_island.cc.services import AuthenticationService from monkey_island.cc.services.authentication import authentication_service -from monkey_island.cc.services.authentication.user_creds import UserCreds USERNAME = "user1" PASSWORD = "test" 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 3681ee7fc..9a8d1eb03 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.models 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, JSONFileUserRepository, ) -from monkey_island.cc.services.authentication.user_creds import UserCreds USERNAME = "test" PASSWORD_HASH = "DEADBEEF"