Beispiel #1
0
 def test_refresh_outbound_context_1(self, mocker):
     """Test out_format=text"""
     import ExportIndicators as ei
     with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f:
         iocs_json = json.loads(iocs_json_f.read())
         mocker.patch.object(ei, 'find_indicators_with_limit', return_value=iocs_json)
         ei_vals = ei.refresh_outbound_context(indicator_query='', out_format='text')
         for ioc in iocs_json:
             ip = ioc.get('value')
             assert ip in ei_vals
Beispiel #2
0
 def test_refresh_outbound_context_4(self, mocker):
     """Test out_format=json-seq"""
     import ExportIndicators as ei
     with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f:
         iocs_json = json.loads(iocs_json_f.read())
         mocker.patch.object(ei, 'find_indicators_with_limit', return_value=iocs_json)
         ei_vals = ei.refresh_outbound_context(indicator_query='', out_format='json-seq')
         with open('ExportIndicators_test/TestHelperFunctions/iocs_out_json_seq.txt', 'r') as iocs_out_f:
             iocs_out = iocs_out_f.read()
             assert iocs_out == ei_vals
 def test_refresh_outbound_context_2(self, mocker):
     """Test out_format= XSOAR json"""
     import ExportIndicators as ei
     with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f:
         iocs_json = json.loads(iocs_json_f.read())
         mocker.patch.object(ei, 'find_indicators_with_limit', return_value=iocs_json)
         request_args = ei.RequestArguments(query='', out_format='XSOAR json', limit=38)
         ei_vals = ei.refresh_outbound_context(request_args)
         assert isinstance(ei_vals, str)
         ei_vals = json.loads(ei_vals)
         assert iocs_json == ei_vals
 def test_refresh_outbound_context_7(self, mocker):
     """Test out_format=csv"""
     import ExportIndicators as ei
     with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f:
         iocs_json = json.loads(iocs_json_f.read())
         mocker.patch.object(ei, 'find_indicators_with_limit', return_value=iocs_json)
         request_args = ei.RequestArguments(query='', out_format='csv', limit=38)
         ei_vals = ei.refresh_outbound_context(request_args)
         with open('ExportIndicators_test/TestHelperFunctions/iocs_out_csv_old.txt', 'r') as iocs_out_f:
             iocs_out = iocs_out_f.read()
             for ioc in iocs_out.split('\n'):
                 assert ioc in ei_vals
Beispiel #5
0
 def test_refresh_outbound_context_4(self, mocker):
     """Test out_format=XSOAR json-seq"""
     import ExportIndicators as ei
     with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f:
         iocs_json = json.loads(iocs_json_f.read())
         iocs_json_result = {'iocs': iocs_json, 'total': 100}
         mocker.patch.object(demisto, 'searchIndicators', return_value=iocs_json_result)
         request_args = ei.RequestArguments(query='', out_format='XSOAR json-seq', limit=38)
         ei_vals = ei.refresh_outbound_context(request_args)
         with open('ExportIndicators_test/TestHelperFunctions/iocs_out_json_seq.txt', 'r') as iocs_out_f:
             iocs_out = iocs_out_f.read()
             assert iocs_out == ei_vals