Skip to content

Commit

Permalink
Merge pull request #55 from CybercentreCanada/feature/signature_status
Browse files Browse the repository at this point in the history
Feature/SignatureStatus (master)
  • Loading branch information
cccs-nr authored Oct 8, 2024
2 parents da0d45a + 3f14663 commit c9f101d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions assemblyline_client/v4_client/module/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ def change_status(self, signature_id, status):
"""
return self._connection.get(api_path_by_module(self, signature_id, status))

def clear_status(self, signature_id):
"""\
Clear the user's status change of a signature
Required:
signature_id : ID of the signature to clear the status
Throws a Client exception if the signature does not exist.
"""
return self._connection.get(api_path_by_module(self, signature_id))

def delete(self, signature_id):
"""\
Delete a signature based off its ID
Expand Down
19 changes: 19 additions & 0 deletions test/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ def test_change_status(datastore, client):
assert signature_data['status'] != new_signature_data['status']


def test_clear_status(datastore, client):
signature_id = random_id_from_collection(datastore, 'signature')
signature_data = datastore.signature.get(signature_id, as_obj=False)

res = client.signature.change_status(signature_id, 'DISABLED')
assert res['success']

new_signature_data = datastore.signature.get(signature_id, as_obj=False)
assert new_signature_data['state_change_date'] is not None
assert new_signature_data['state_change_user'] is not None

res = client.signature.clear_status(signature_id)
assert res['success']

new_signature_data = datastore.signature.get(signature_id, as_obj=False)
assert new_signature_data['state_change_date'] is None
assert new_signature_data['state_change_user'] is None


def test_delete(datastore, client):
signature_id = random_id_from_collection(datastore, 'signature')
res = client.signature.delete(signature_id)
Expand Down

0 comments on commit c9f101d

Please sign in to comment.