def test_scan_element_sources_all_invalid_child_data_should_raise(self): """ Test scanElementSourcesAll(self, instanceId, childData) """ sfdb = SpiderFootDb(self.default_options, False) invalid_types = [None, "", dict()] for invalid_type in invalid_types: with self.subTest(invalid_type=invalid_type): with self.assertRaises(TypeError) as cm: scan_element_sources_all = sfdb.scanElementSourcesAll( "", invalid_type) with self.assertRaises(ValueError) as cm: scan_element_sources_all = sfdb.scanElementSourcesAll("", list())
def test_scan_element_sources_all_should_return_a_list(self): """ Test scanElementSourcesAll(self, instanceId, childData) """ sfdb = SpiderFootDb(self.default_options, False) scan_element_sources_all = sfdb.scanElementSourcesAll(None, list()) self.assertIsInstance(scan_element_sources_all, list) self.assertEqual('TBD', 'TBD')
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) as cm: scan_element_sources_all = 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) as cm: scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, invalid_type)
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')
def scanelementtypediscovery(self, id, eventType): 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, ensure_ascii=False)
def scanelementtypediscovery(self, id, eventType): 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, ensure_ascii=False)