Island: Rename IUserDatastore -> IUserRepository

This commit is contained in:
Mike Salvatore 2022-07-12 08:06:21 -04:00
parent 96a7968565
commit 50d08c3aef
5 changed files with 9 additions and 9 deletions

View File

@ -13,12 +13,12 @@ from monkey_island.cc.server_utils.encryption import (
) )
from monkey_island.cc.setup.mongo.database_initializer import reset_database from monkey_island.cc.setup.mongo.database_initializer import reset_database
from .i_user_datastore import IUserDatastore from .i_user_datastore import IUserRepository
from .user_creds import UserCreds from .user_creds import UserCreds
class AuthenticationService: class AuthenticationService:
def __init__(self, data_dir: Path, user_datastore: IUserDatastore): def __init__(self, data_dir: Path, user_datastore: IUserRepository):
self._data_dir = data_dir self._data_dir = data_dir
self._user_datastore = user_datastore self._user_datastore = user_datastore

View File

@ -3,7 +3,7 @@ import abc
from .user_creds import UserCreds from .user_creds import UserCreds
class IUserDatastore(metaclass=abc.ABCMeta): class IUserRepository(metaclass=abc.ABCMeta):
""" """
Allows user credentials to be stored and retrieved. Allows user credentials to be stored and retrieved.
""" """

View File

@ -8,13 +8,13 @@ from common.utils.exceptions import (
) )
from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file from monkey_island.cc.server_utils.file_utils import open_new_securely_permissioned_file
from .i_user_datastore import IUserDatastore from .i_user_datastore import IUserRepository
from .user_creds import UserCreds from .user_creds import UserCreds
CREDENTIALS_FILE = "credentials.json" CREDENTIALS_FILE = "credentials.json"
class JsonFileUserDatastore(IUserDatastore): class JsonFileUserDatastore(IUserRepository):
def __init__(self, data_dir: Path): def __init__(self, data_dir: Path):
self._credentials = None self._credentials = None
self._credentials_file = data_dir / CREDENTIALS_FILE self._credentials_file = data_dir / CREDENTIALS_FILE

View File

@ -41,7 +41,7 @@ from monkey_island.cc.services.telemetry.processing.processing import (
from monkey_island.cc.setup.mongo.mongo_setup import MONGO_URL from monkey_island.cc.setup.mongo.mongo_setup import MONGO_URL
from . import AuthenticationService, JsonFileUserDatastore from . import AuthenticationService, JsonFileUserDatastore
from .authentication.i_user_datastore import IUserDatastore from .authentication.i_user_datastore import IUserRepository
from .reporting.report import ReportService from .reporting.report import ReportService
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -95,7 +95,7 @@ def _register_repositories(container: DIContainer, data_dir: Path):
container.register_instance( container.register_instance(
ICredentialsRepository, container.resolve(MongoCredentialsRepository) ICredentialsRepository, container.resolve(MongoCredentialsRepository)
) )
container.register_instance(IUserDatastore, container.resolve(JsonFileUserDatastore)) container.register_instance(IUserRepository, container.resolve(JsonFileUserDatastore))
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository: def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:

View File

@ -10,7 +10,7 @@ from common.utils.exceptions import (
) )
from monkey_island.cc.services import AuthenticationService from monkey_island.cc.services import AuthenticationService
from monkey_island.cc.services.authentication import authentication_service 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.i_user_datastore import IUserRepository
from monkey_island.cc.services.authentication.user_creds import UserCreds from monkey_island.cc.services.authentication.user_creds import UserCreds
USERNAME = "user1" USERNAME = "user1"
@ -18,7 +18,7 @@ PASSWORD = "test"
PASSWORD_HASH = "$2b$12$YsGjjuJFddYJ6z5S5/nMCuKkCzKHB1AWY9SXkQ02i25d8TgdhIRS2" PASSWORD_HASH = "$2b$12$YsGjjuJFddYJ6z5S5/nMCuKkCzKHB1AWY9SXkQ02i25d8TgdhIRS2"
class MockUserDatastore(IUserDatastore): class MockUserDatastore(IUserRepository):
def __init__(self, has_registered_users, add_user, get_user_credentials): def __init__(self, has_registered_users, add_user, get_user_credentials):
self._has_registered_users = has_registered_users self._has_registered_users = has_registered_users
self._add_user = add_user self._add_user = add_user