Skip to content

Commit

Permalink
[IMP] Changed success response format of endpoint PUT /api/v2/iocs/{i…
Browse files Browse the repository at this point in the history
…dentifier} to respect API v2 rules
  • Loading branch information
c8y3 committed Oct 16, 2024
1 parent a60a5f7 commit a32e1d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from app.models.authorization import CaseAccessLevel
from app.schema.marshables import IocSchemaForAPIV2
from app.blueprints.access_controls import ac_api_return_access_denied
from app.blueprints.responses import response_success
from app.blueprints.responses import response_error

api_v2_ioc_blueprint = Blueprint('case_ioc_rest_v2',
Expand Down Expand Up @@ -153,7 +152,7 @@ def update_ioc(identifier):

try:
ioc, msg = iocs_update(identifier, request.get_json())
return response_success(msg, data=ioc_schema.dump(ioc))
return response_api_success(ioc_schema.dump(ioc))
except BusinessProcessingError as e:
return response_error(e.get_message(), data=e.get_data())

Expand Down
9 changes: 9 additions & 0 deletions tests/tests_rest_iocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ def test_update_ioc_should_not_fail(self):
ioc_identifier = response['ioc_id']
response = self._subject.update(f'/api/v2/iocs/{ioc_identifier}', {'ioc_value': '9.9.9.9'})
self.assertEqual(200, response.status_code)

def test_update_ioc_should_return_updated_value(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']
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'])

0 comments on commit a32e1d6

Please sign in to comment.