Island: Rename JsonFileUserDatastore -> JSONFileUserRepository
This commit is contained in:
parent
50d08c3aef
commit
7c98ca0004
|
@ -1,5 +1,5 @@
|
||||||
from .authentication.authentication_service import AuthenticationService
|
from .authentication.authentication_service import AuthenticationService
|
||||||
from .authentication.json_file_user_datastore import JsonFileUserDatastore
|
from .authentication.json_file_user_datastore import JSONFileUserRepository
|
||||||
|
|
||||||
from .aws import AWSService
|
from .aws import AWSService
|
||||||
from .island_mode_service import IslandModeService
|
from .island_mode_service import IslandModeService
|
||||||
|
|
|
@ -14,7 +14,7 @@ from .user_creds import UserCreds
|
||||||
CREDENTIALS_FILE = "credentials.json"
|
CREDENTIALS_FILE = "credentials.json"
|
||||||
|
|
||||||
|
|
||||||
class JsonFileUserDatastore(IUserRepository):
|
class JSONFileUserRepository(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
|
||||||
|
|
|
@ -40,7 +40,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, JSONFileUserRepository
|
||||||
from .authentication.i_user_datastore import IUserRepository
|
from .authentication.i_user_datastore import IUserRepository
|
||||||
from .reporting.report import ReportService
|
from .reporting.report import ReportService
|
||||||
|
|
||||||
|
@ -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(IUserRepository, container.resolve(JsonFileUserDatastore))
|
container.register_instance(IUserRepository, container.resolve(JSONFileUserRepository))
|
||||||
|
|
||||||
|
|
||||||
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:
|
def _decorate_file_repository(file_repository: IFileRepository) -> IFileRepository:
|
||||||
|
|
|
@ -12,7 +12,7 @@ from common.utils.exceptions import (
|
||||||
from monkey_island.cc.server_utils.file_utils import is_windows_os
|
from monkey_island.cc.server_utils.file_utils import is_windows_os
|
||||||
from monkey_island.cc.services.authentication.json_file_user_datastore import (
|
from monkey_island.cc.services.authentication.json_file_user_datastore import (
|
||||||
CREDENTIALS_FILE,
|
CREDENTIALS_FILE,
|
||||||
JsonFileUserDatastore,
|
JSONFileUserRepository,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.services.authentication.user_creds import UserCreds
|
from monkey_island.cc.services.authentication.user_creds import UserCreds
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ PASSWORD_HASH = "DEADBEEF"
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_datastore(tmp_path):
|
def empty_datastore(tmp_path):
|
||||||
return JsonFileUserDatastore(tmp_path)
|
return JSONFileUserRepository(tmp_path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def populated_datastore(data_for_tests_dir):
|
def populated_datastore(data_for_tests_dir):
|
||||||
return JsonFileUserDatastore(data_for_tests_dir)
|
return JSONFileUserRepository(data_for_tests_dir)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -91,10 +91,10 @@ def test_add_user__already_registered(populated_datastore):
|
||||||
|
|
||||||
|
|
||||||
def test_get_user_credentials_from_file(tmp_path):
|
def test_get_user_credentials_from_file(tmp_path):
|
||||||
empty_datastore = JsonFileUserDatastore(tmp_path)
|
empty_datastore = JSONFileUserRepository(tmp_path)
|
||||||
empty_datastore.add_user(UserCreds(USERNAME, PASSWORD_HASH))
|
empty_datastore.add_user(UserCreds(USERNAME, PASSWORD_HASH))
|
||||||
|
|
||||||
populated_datastore = JsonFileUserDatastore(tmp_path)
|
populated_datastore = JSONFileUserRepository(tmp_path)
|
||||||
stored_user = populated_datastore.get_user_credentials(USERNAME)
|
stored_user = populated_datastore.get_user_credentials(USERNAME)
|
||||||
|
|
||||||
assert stored_user.username == USERNAME
|
assert stored_user.username == USERNAME
|
||||||
|
|
Loading…
Reference in New Issue