From 9b7c9c4ffa35306bb07c30ad0dd0e6e54c343938 Mon Sep 17 00:00:00 2001 From: c8y3 <25362953+c8y3@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:21:26 +0200 Subject: [PATCH] [IMP] Added test of error case of PUT /api/v2/iocs/{identifier} --- source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py | 2 +- tests/tests_rest_iocs.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py b/source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py index d3383cceb..b338cb9f0 100644 --- a/source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py +++ b/source/app/blueprints/rest/v2/case/api_v2_ioc_routes.py @@ -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()) diff --git a/tests/tests_rest_iocs.py b/tests/tests_rest_iocs.py index 2885b0fff..e1dcd02fb 100644 --- a/tests/tests_rest_iocs.py +++ b/tests/tests_rest_iocs.py @@ -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) +