def test_scanElementSourcesAll_argument_childData_with_empty_value_should_raise_ValueError(self): """ Test scanElementSourcesAll(self, instanceId, childData) """ sfdb = SpiderFootDb(self.default_options, False) instance_id = "example instance id" child_data = [] with self.assertRaises(ValueError): sfdb.scanElementSourcesAll(instance_id, child_data)
def test_scanElementSourcesAll_argument_childData_of_invalid_type_should_raise_TypeError(self): """ Test scanElementSourcesAll(self, instanceId, childData) """ sfdb = SpiderFootDb(self.default_options, False) instance_id = "example instance id" invalid_types = [None, "", dict(), int()] for invalid_type in invalid_types: with self.subTest(invalid_type=invalid_type): with self.assertRaises(TypeError): sfdb.scanElementSourcesAll(instance_id, invalid_type)
def scanelementtypediscovery(self, id, eventType): """scan element type discovery Args: id: TBD eventType (str): filter by event type """ cherrypy.response.headers['Content-Type'] = "application/json; charset=utf-8" sf = SpiderFoot(self.config) dbh = SpiderFootDb(self.config) pc = dict() datamap = dict() # Get the events we will be tracing back from leafSet = dbh.scanResultEvent(id, eventType) [datamap, pc] = dbh.scanElementSourcesAll(id, leafSet) # Delete the ROOT key as it adds no value from a viz perspective del pc['ROOT'] retdata = dict() retdata['tree'] = sf.dataParentChildToTree(pc) retdata['data'] = datamap return json.dumps(retdata).encode('utf-8')
def scanelementtypediscovery(self, id, eventType): """Scan element type discovery. Args: id (str): scan ID eventType (str): filter by event type Returns: str: JSON """ dbh = SpiderFootDb(self.config) pc = dict() datamap = dict() retdata = dict() # Get the events we will be tracing back from try: leafSet = dbh.scanResultEvent(id, eventType) [datamap, pc] = dbh.scanElementSourcesAll(id, leafSet) except Exception: return retdata # Delete the ROOT key as it adds no value from a viz perspective del pc['ROOT'] retdata['tree'] = SpiderFootHelpers.dataParentChildToTree(pc) retdata['data'] = datamap return retdata
def test_scanElementSourcesAll_should_return_a_list(self): """ Test scanElementSourcesAll(self, instanceId, childData) """ sfdb = SpiderFootDb(self.default_options, False) instance_id = "example instance id" child_data = ["example child", "example child"] scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, child_data) self.assertIsInstance(scan_element_sources_all, list) self.assertEqual('TBD', 'TBD')