Skip to content

Commit

Permalink
[IMP] Added test of error case of PUT /api/v2/iocs/{identifier}
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Oct 16, 2024
1 parent 4017efa commit 9b7c9c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ def update_ioc(identifier):
return response_api_not_found()

except BusinessProcessingError as e:
return response_error(e.get_message(), data=e.get_data())
return response_api_error(e.get_message(), data=e.get_data())
9 changes: 9 additions & 0 deletions tests/tests_rest_iocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,12 @@ def test_update_ioc_should_return_updated_value(self):
new_value = '9.9.9.9'
response = self._subject.update(f'/api/v2/iocs/{ioc_identifier}', {'ioc_value': new_value}).json()
self.assertEqual(new_value, response['ioc_value'])

def test_update_ioc_should_return_an_error_when_ioc_type_identifier_is_out_of_range(self):
case_identifier = self._subject.create_dummy_case()
body = {'ioc_type_id': 1, 'ioc_tlp_id': 2, 'ioc_value': '8.8.8.8', 'ioc_description': 'rewrw', 'ioc_tags': ''}
response = self._subject.create(f'/api/v2/cases/{case_identifier}/iocs', body).json()
ioc_identifier = response['ioc_id']
response = self._subject.update(f'/api/v2/iocs/{ioc_identifier}', {'ioc_type_id': '123456789'})
self.assertEqual(400, response.status_code)

0 comments on commit 9b7c9c4

Please sign in to comment.