SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Tests: test_sfp_intfiles: Add handleEvent tests (#1478)
bcoles74f5a68e4cdc
diff --git a/test/unit/modules/test_sfp_intfiles.py b/test/unit/modules/test_sfp_intfiles.pyindex d1188998..89c155f3 100644--- a/test/unit/modules/test_sfp_intfiles.py+++ b/test/unit/modules/test_sfp_intfiles.py@@ -34,26 +34,76 @@ class TestModuleintfiles(unittest.TestCase):module = sfp_intfiles()self.assertIsInstance(module.producedEvents(), list)- def test_handleEvent(self):- """- Test handleEvent(self, event)- """+ def test_handleEvent_event_data_internal_url_with_interesting_file_extension_should_return_event(self):sf = SpiderFoot(self.default_options)module = sfp_intfiles()module.setup(sf, dict())- target_value = 'example target value'- target_type = 'IP_ADDRESS'+ target_value = 'spiderfoot.net'+ target_type = 'INTERNET_NAME'target = SpiderFootTarget(target_value, target_type)module.setTarget(target)+ def new_notifyListeners(self, event):+ expected = 'INTERESTING_FILE'+ if str(event.eventType) != expected:+ raise Exception(f"{event.eventType} != {expected}")++ expected = 'https://spiderfoot.net/example.zip'+ if str(event.data) != expected:+ raise Exception(f"{event.data} != {expected}")++ raise Exception("OK")++ module.notifyListeners = new_notifyListeners.__get__(module, sfp_intfiles)+event_type = 'ROOT'event_data = 'example data'event_module = ''source_event = ''evt = SpiderFootEvent(event_type, event_data, event_module, source_event)+ event_type = 'LINKED_URL_INTERNAL'+ event_data = 'https://spiderfoot.net/example.zip'+ event_module = 'example module'+ source_event = evt++ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)++ with self.assertRaises(Exception) as cm:+ module.handleEvent(evt)++ self.assertEqual("OK", str(cm.exception))++ def test_handleEvent_event_data_internal_url_without_interesting_file_extension_should_not_return_event(self):+ sf = SpiderFoot(self.default_options)++ module = sfp_intfiles()+ module.setup(sf, dict())++ target_value = 'spiderfoot.net'+ target_type = 'INTERNET_NAME'+ target = SpiderFootTarget(target_value, target_type)+ module.setTarget(target)++ def new_notifyListeners(self, event):+ raise Exception(f"Raised event {event.eventType}: {event.data}")++ module.notifyListeners = new_notifyListeners.__get__(module, sfp_intfiles)++ event_type = 'ROOT'+ event_data = 'example data'+ event_module = ''+ source_event = ''+ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)++ event_type = 'LINKED_URL_INTERNAL'+ event_data = 'https://spiderfoot.net/example'+ event_module = 'example module'+ source_event = evt++ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)result = module.handleEvent(evt)self.assertIsNone(result)