Island: Rename IUserDatastore -> IUserRepository
This commit is contained in:
parent
96a7968565
commit
50d08c3aef
|
@ -13,12 +13,12 @@ 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 .i_user_datastore import IUserRepository
|
||||
from .user_creds import UserCreds
|
||||
|
||||
|
||||
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._user_datastore = user_datastore
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import abc
|
|||
from .user_creds import UserCreds
|
||||
|
||||
|
||||
class IUserDatastore(metaclass=abc.ABCMeta):
|
||||
class IUserRepository(metaclass=abc.ABCMeta):
|
||||
"""
|
||||
Allows user credentials to be stored and retrieved.
|
||||
"""
|
||||
|
|
|
@ -8,13 +8,13 @@ from common.utils.exceptions import (
|
|||
)
|
||||
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
|
||||
|
||||
CREDENTIALS_FILE = "credentials.json"
|
||||
|
||||
|
||||
class JsonFileUserDatastore(IUserDatastore):
|
||||
class JsonFileUserDatastore(IUserRepository):
|
||||
def __init__(self, data_dir: Path):
|
||||
self._credentials = None
|
||||
self._credentials_file = data_dir / CREDENTIALS_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 . import AuthenticationService, JsonFileUserDatastore
|
||||
from .authentication.i_user_datastore import IUserDatastore
|
||||
from .authentication.i_user_datastore import IUserRepository
|
||||
from .reporting.report import ReportService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -95,7 +95,7 @@ def _register_repositories(container: DIContainer, data_dir: Path):
|
|||
container.register_instance(
|
||||
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:
|
||||
|
|
|
@ -10,7 +10,7 @@ from common.utils.exceptions import (
|
|||
)
|
||||
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.i_user_datastore import IUserRepository
|
||||
from monkey_island.cc.services.authentication.user_creds import UserCreds
|
||||
|
||||
USERNAME = "user1"
|
||||
|
@ -18,7 +18,7 @@ PASSWORD = "test"
|
|||
PASSWORD_HASH = "$2b$12$YsGjjuJFddYJ6z5S5/nMCuKkCzKHB1AWY9SXkQ02i25d8TgdhIRS2"
|
||||
|
||||
|
||||
class MockUserDatastore(IUserDatastore):
|
||||
class MockUserDatastore(IUserRepository):
|
||||
def __init__(self, has_registered_users, add_user, get_user_credentials):
|
||||
self._has_registered_users = has_registered_users
|
||||
self._add_user = add_user
|
||||
|
|
Loading…
Reference in New Issue