Island: Add ICredentialsRepository.reset()

This commit is contained in:
Mike Salvatore 2022-09-15 12:00:04 -04:00
parent 07815eed93
commit 3fd27c6503
4 changed files with 18 additions and 0 deletions

View File

@ -84,3 +84,10 @@ class ICredentialsRepository(ABC):
:raises RemovalError: If an error is encountered while attempting to remove the credentials :raises RemovalError: If an error is encountered while attempting to remove the credentials
""" """
pass pass
def reset(self):
"""
An alias for remove_all_credentials()
:raises RemovalError: If an error is encountered while attempting to remove the credentials
"""

View File

@ -52,6 +52,9 @@ class MongoCredentialsRepository(ICredentialsRepository):
self.remove_configured_credentials() self.remove_configured_credentials()
self.remove_stolen_credentials() self.remove_stolen_credentials()
def reset(self):
self.remove_all_credentials()
def _get_credentials_from_collection(self, collection) -> Sequence[Credentials]: def _get_credentials_from_collection(self, collection) -> Sequence[Credentials]:
try: try:
collection_result = [] collection_result = []

View File

@ -33,3 +33,6 @@ class InMemoryCredentialsRepository(ICredentialsRepository):
def remove_all_credentials(self): def remove_all_credentials(self):
self.remove_configured_credentials() self.remove_configured_credentials()
self.remove_stolen_credentials() self.remove_stolen_credentials()
def reset(self):
self.remove_all_credentials()

View File

@ -142,6 +142,11 @@ def test_mongo_repository_remove_credentials__removal_error(error_raising_creden
error_raising_credentials_repository.remove_stolen_credentials() error_raising_credentials_repository.remove_stolen_credentials()
def test_mongo_repository_reset__removal_error(error_raising_credentials_repository):
with pytest.raises(RemovalError):
error_raising_credentials_repository.reset()
@pytest.mark.parametrize("credentials", CREDENTIALS) @pytest.mark.parametrize("credentials", CREDENTIALS)
def test_configured_secrets_encrypted( def test_configured_secrets_encrypted(
mongo_repository: MongoCredentialsRepository, mongo_repository: MongoCredentialsRepository,