Skip to content

Commit

Permalink
[IMP] For endpoint GET /api/v2/cases/{identifier}/iocs, changed field…
Browse files Browse the repository at this point in the history
… iocs into data
  • Loading branch information
c8y3 committed Oct 4, 2024
1 parent 37f02df commit d764534
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions source/app/blueprints/rest/case/case_ioc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ def list_ioc(identifier):

iocs = {
'total': filtered_iocs.total,
# TODO should maybe really uniform all return types of paginated list and replace field iocs by field data
'iocs': iocs,
'data': iocs,
'last_page': filtered_iocs.pages,
'current_page': filtered_iocs.page,
'next_page': filtered_iocs.next_num if filtered_iocs.has_next else None,
Expand Down
8 changes: 4 additions & 4 deletions tests/tests_rest_iocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_get_ioc_should_not_fail(self):
response = self._subject.get('/case/ioc/list').json()
self.assertEqual('success', response['status'])

def test_create_ioc_should_return_good_ioc_type_id(self):
def test_create_ioc_should_return_correct_ioc_type_id(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()
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_get_iocs_should_filter_and_return_ioc_type_identifier(self):
filters = {'ioc_value': 'test_get_iocs_should_filter_on_ioc_value'}
response = self._subject.get(f'/api/v2/cases/{case_identifier}/iocs', query_parameters=filters).json()
identifiers = []
for ioc in response['iocs']:
for ioc in response['data']:
identifiers.append(ioc['ioc_type_id'])
self.assertIn(ioc_type_identifier, identifiers)

Expand All @@ -125,7 +125,7 @@ def test_get_iocs_should_include_tlp_information(self):
body = {'ioc_type_id': 1, 'ioc_tlp_id': tlp_identifier, 'ioc_value': '8.8.8.8', 'ioc_description': 'rewrw', 'ioc_tags': ''}
self._subject.create(f'/api/v2/cases/{case_identifier}/iocs', body).json()
response = self._subject.get(f'/api/v2/cases/{case_identifier}/iocs').json()
self.assertEqual(tlp_identifier, response['iocs'][0]['tlp']['tlp_id'])
self.assertEqual(tlp_identifier, response['data'][0]['tlp']['tlp_id'])

def test_get_iocs_should_include_link_to_other_cases_with_same_value_type_ioc(self):
case_identifier1 = self._subject.create_dummy_case()
Expand All @@ -135,7 +135,7 @@ def test_get_iocs_should_include_link_to_other_cases_with_same_value_type_ioc(se
body = {'ioc_type_id': 1, 'ioc_tlp_id': 1, 'ioc_value': '8.8.8.8', 'ioc_description': 'another', 'ioc_tags': ''}
self._subject.create(f'/api/v2/cases/{case_identifier2}/iocs', body).json()
response = self._subject.get(f'/api/v2/cases/{case_identifier2}/iocs').json()
self.assertEqual(case_identifier1, response['iocs'][0]['link'][0]['case_id'])
self.assertEqual(case_identifier1, response['data'][0]['link'][0]['case_id'])

def test_create_ioc_should_include_field_link(self):
case_identifier = self._subject.create_dummy_case()
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/case.ioc.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function get_case_ioc() {
}

Table.clear();
Table.rows.add(data.iocs);
Table.rows.add(data.data);

$('#ioc_table_wrapper').on('click', function(e){
if($('.popover').length>1)
Expand Down

0 comments on commit d764534

Please sign in to comment.