Skip to content

Commit

Permalink
Merge pull request #36 from Covata/delete-secret
Browse files Browse the repository at this point in the history
Delete secret
  • Loading branch information
myuwono committed Feb 20, 2017
2 parents d03371d + 52ffb29 commit 3c3405b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/python/covata/delta/api/requestsclient.py
Expand Up @@ -137,6 +137,15 @@ def get_secret(self, requestor_id, secret_id):
secret["encryptionDetails"][k] = b64decode(v)
return secret

def delete_secret(self, requestor_id, secret_id):
response = requests.delete(
url="{base_url}{resource}/{secret_id}".format(
base_url=self.DELTA_URL,
resource=self.RESOURCE_SECRETS,
secret_id=secret_id),
auth=self.signer(requestor_id))
response.raise_for_status()

def update_secret_metadata(self,
requestor_id, secret_id, metadata, version):
response = requests.put(
Expand Down
9 changes: 9 additions & 0 deletions src/main/python/covata/delta/interfaces.py
Expand Up @@ -98,6 +98,15 @@ def share_secret(self, requestor_id, content, encryption_details,
:rtype: dict[str, str]
"""

@abstractmethod
def delete_secret(self, requestor_id, secret_id):
"""
Deletes the secret with the given secret id.
:param str requestor_id: the authenticating identity id
:param str secret_id: the secret id to be deleted
"""

@abstractmethod
def get_secret(self, requestor_id, secret_id):
"""
Expand Down
19 changes: 19 additions & 0 deletions src/unittest/python/test_requests_api_client.py
Expand Up @@ -256,6 +256,25 @@ def test_get_secret(api_client, mock_signer):
assert response == expected_json


@responses.activate
def test_delete_secret(api_client, mock_signer):
requestor_id = "requestor_id"
secret_id = "secret_id"

responses.add(responses.DELETE,
"{base_path}{resource}/{secret_id}".format(
base_path=DeltaApiClient.DELTA_URL,
resource=DeltaApiClient.RESOURCE_SECRETS,
secret_id=secret_id),
status=204)

api_client.delete_secret(requestor_id, secret_id)

mock_signer.assert_called_once_with(requestor_id)

assert len(responses.calls) == 1


@responses.activate
def test_get_secret_metadata(api_client, mock_signer):
response_json = dict(metadata_key="metadata value")
Expand Down

0 comments on commit 3c3405b

Please sign in to comment.