Island: Modify ICredentialsRepository to save a Sequence of Credentials

This commit is contained in:
Mike Salvatore 2022-07-07 13:06:38 -04:00
parent 68fe2edd08
commit 7bcf49daf9
3 changed files with 8 additions and 8 deletions

View File

@ -43,7 +43,7 @@ class ICredentialsRepository(ABC):
""" """
pass pass
def save_configured_credentials(self, credentials: Credentials): def save_configured_credentials(self, credentials: Sequence[Credentials]):
""" """
Save credentials that were configured. Save credentials that were configured.
@ -52,7 +52,7 @@ class ICredentialsRepository(ABC):
""" """
pass pass
def save_stolen_credentials(self, credentials: Credentials): def save_stolen_credentials(self, credentials: Sequence[Credentials]):
""" """
Save credentials that were stolen during a simulation. Save credentials that were stolen during a simulation.

View File

@ -34,15 +34,15 @@ class MongoCredentialsRepository(ICredentialsRepository):
except RetrievalError as err: except RetrievalError as err:
raise err raise err
def save_configured_credentials(self, credentials: Credentials): def save_configured_credentials(self, credentials: Sequence[Credentials]):
try: try:
mongo.db.configured_credentials.insert_one(credentials) mongo.db.configured_credentials.insert_many(credentials)
except Exception as err: except Exception as err:
raise StorageError(err) raise StorageError(err)
def save_stolen_credentials(self, credentials: Credentials): def save_stolen_credentials(self, credentials: Sequence[Credentials]):
try: try:
mongo.db.stolen_credentials.insert_one(credentials) mongo.db.stolen_credentials.insert_many(credentials)
except Exception as err: except Exception as err:
raise StorageError(err) raise StorageError(err)

View File

@ -47,10 +47,10 @@ class StubPropagationCredentialsRepository(ICredentialsRepository):
Credentials.from_mapping(PROPAGATION_CREDENTIALS_2, monkey_guid="second_guid"), Credentials.from_mapping(PROPAGATION_CREDENTIALS_2, monkey_guid="second_guid"),
] ]
def save_configured_credentials(self, credentials: Credentials): def save_configured_credentials(self, credentials: Sequence[Credentials]):
pass pass
def save_stolen_credentials(self, credentials: Credentials): def save_stolen_credentials(self, credentials: Sequence[Credentials]):
pass pass
def remove_configured_credentials(self): def remove_configured_credentials(self):