Island: Fix minor things in MongoCredentialsRepository and credentials
endpoint
This commit is contained in:
parent
0cee5ac00d
commit
55f95891e1
|
@ -15,19 +15,13 @@ class MongoCredentialsRepository(ICredentialsRepository):
|
|||
|
||||
def __init__(self, mongo: MongoClient, repository_encryptor: ILockableEncryptor):
|
||||
self._database = mongo.monkeyisland
|
||||
|
||||
self._repository_encryptor = repository_encryptor
|
||||
|
||||
def get_configured_credentials(self) -> Sequence[Credentials]:
|
||||
return MongoCredentialsRepository._get_credentials_from_collection(
|
||||
self._database.configured_credentials
|
||||
)
|
||||
|
||||
return self._get_credentials_from_collection(self._database.configured_credentials)
|
||||
|
||||
def get_stolen_credentials(self) -> Sequence[Credentials]:
|
||||
return MongoCredentialsRepository._get_credentials_from_collection(
|
||||
self._database.stolen_credentials
|
||||
)
|
||||
|
||||
return self._get_credentials_from_collection(self._database.stolen_credentials)
|
||||
|
||||
def get_all_credentials(self) -> Sequence[Credentials]:
|
||||
configured_credentials = self.get_configured_credentials()
|
||||
|
@ -37,26 +31,16 @@ class MongoCredentialsRepository(ICredentialsRepository):
|
|||
|
||||
def save_configured_credentials(self, credentials: Sequence[Credentials]):
|
||||
# TODO: Fix deduplication of Credentials in mongo
|
||||
MongoCredentialsRepository._save_credentials_to_collection(
|
||||
credentials, self._database.configured_credentials
|
||||
)
|
||||
|
||||
self._save_credentials_to_collection(credentials, self._database.configured_credentials)
|
||||
|
||||
def save_stolen_credentials(self, credentials: Sequence[Credentials]):
|
||||
MongoCredentialsRepository._save_credentials_to_collection(
|
||||
credentials, self._database.stolen_credentials
|
||||
)
|
||||
|
||||
self._save_credentials_to_collection(credentials, self._database.stolen_credentials)
|
||||
|
||||
def remove_configured_credentials(self):
|
||||
MongoCredentialsRepository._remove_credentials_fom_collection(
|
||||
self._database.configured_credentials
|
||||
)
|
||||
self._remove_credentials_fom_collection(self._database.configured_credentials)
|
||||
|
||||
def remove_stolen_credentials(self):
|
||||
MongoCredentialsRepository._remove_credentials_fom_collection(
|
||||
self._database.stolen_credentials
|
||||
)
|
||||
self._remove_credentials_fom_collection(self._database.stolen_credentials)
|
||||
|
||||
def remove_all_credentials(self):
|
||||
self.remove_configured_credentials()
|
||||
|
|
|
@ -29,7 +29,7 @@ class PropagationCredentials(AbstractResource):
|
|||
return propagation_credentials, HTTPStatus.OK
|
||||
|
||||
def post(self, collection=None):
|
||||
credentials = [Credentials.from_mapping(c) for c in request.json]
|
||||
credentials = [Credentials.from_json(c) for c in request.json]
|
||||
|
||||
if collection == _configured_collection:
|
||||
self._credentials_repository.save_configured_credentials(credentials)
|
||||
|
|
Loading…
Reference in New Issue