Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/SignatureStatus (master) #55

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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