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.json_file_user_datastore import JsonFileUserDatastore
|
||||
from .authentication.json_file_user_datastore import JSONFileUserRepository
|
||||
|
||||
from .aws import AWSService
|
||||
from .island_mode_service import IslandModeService
|
||||
|
|
|
@ -14,7 +14,7 @@ from .user_creds import UserCreds
|
|||
CREDENTIALS_FILE = "credentials.json"
|
||||
|
||||
|
||||
class JsonFileUserDatastore(IUserRepository):
|
||||
class JSONFileUserRepository(IUserRepository):
|
||||
def __init__(self, data_dir: Path):
|
||||
self._credentials = None
|
||||
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 . import AuthenticationService, JsonFileUserDatastore
|
||||
from . import AuthenticationService, JSONFileUserRepository
|
||||
from .authentication.i_user_datastore import IUserRepository
|
||||
from .reporting.report import ReportService
|
||||
|
||||
|
@ -95,7 +95,7 @@ def _register_repositories(container: DIContainer, data_dir: Path):
|
|||
container.register_instance(
|
||||
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:
|
||||
|
|
|
@ -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.services.authentication.json_file_user_datastore import (
|
||||
CREDENTIALS_FILE,
|
||||
JsonFileUserDatastore,
|
||||
JSONFileUserRepository,
|
||||
)
|
||||
from monkey_island.cc.services.authentication.user_creds import UserCreds
|
||||
|
||||
|
@ -22,12 +22,12 @@ PASSWORD_HASH = "DEADBEEF"
|
|||
|
||||
@pytest.fixture
|
||||
def empty_datastore(tmp_path):
|
||||
return JsonFileUserDatastore(tmp_path)
|
||||
return JSONFileUserRepository(tmp_path)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def populated_datastore(data_for_tests_dir):
|
||||
return JsonFileUserDatastore(data_for_tests_dir)
|
||||
return JSONFileUserRepository(data_for_tests_dir)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -91,10 +91,10 @@ def test_add_user__already_registered(populated_datastore):
|
|||
|
||||
|
||||
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))
|
||||
|
||||
populated_datastore = JsonFileUserDatastore(tmp_path)
|
||||
populated_datastore = JSONFileUserRepository(tmp_path)
|
||||
stored_user = populated_datastore.get_user_credentials(USERNAME)
|
||||
|
||||
assert stored_user.username == USERNAME
|
||||
|
|
Loading…
Reference in New Issue