コード例 #1
0
 def test_entity_query_csv(self):
     query = {
         "entity": {
             "type": "AttackVector",
         },
         "output": {
             "format": "csv"
         }
     }
     api = RawApiClient()
     resp = api.paged_query(query, limit=30, batch_size=10)
     head = next(resp)
     self.assertIsInstance(head, list)
     for a in resp:
         self.assertIsInstance(a, dict)
コード例 #2
0
 def test_paging_aggregate_query_fails(self):
     with self.assertRaises(rfapi.error.InvalidRFQError):
         client = RawApiClient()
         query = {
             "instance": {
                 "type": "Acquisition",
             },
             "output": {
                 "count": {
                     "axis": ["publication_year"],
                     "values": ["instances"]
                 }
             }
         }
         next(client.paged_query(query))
コード例 #3
0
 def test_enrichment_query_csv(self):
     query = {
         "cluster": {
             "data_group": "IpAddress",
         },
         "output": {
             "format": "csv/splunk",
             "inline_entities": False
         }
     }
     api = RawApiClient()
     resp = api.paged_query(query, limit=30, batch_size=10)
     head = next(resp)
     self.assertIsInstance(head, list)
     for a in resp:
         self.assertIsInstance(a, dict)
コード例 #4
0
 def test_page_xml(self):
     client = RawApiClient()
     query = {
         "cluster": {
             "data_group": "IpAddress"
         },
         "output": {
             "format": "xml/stix"
         }
     }
     limit = 30
     responses = [
         resp
         for resp in client.paged_query(query, batch_size=10, limit=limit)
     ]
     total_count = responses[0].total_count
     n_results = sum(map(lambda r: r.returned_count, responses))
     self.assertEqual(n_results, min(limit, total_count))