SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Tests: test_sfp_social: Add handleEvent tests (#1399)
bcoles76bb2898e5c1
diff --git a/test/unit/modules/test_sfp_social.py b/test/unit/modules/test_sfp_social.pyindex 0e78a032..81292603 100644--- a/test/unit/modules/test_sfp_social.py+++ b/test/unit/modules/test_sfp_social.py@@ -34,26 +34,64 @@ class TestModulesocial(unittest.TestCase):module = sfp_social()self.assertIsInstance(module.producedEvents(), list)- def test_handleEvent(self):- """- Test handleEvent(self, event)- """+ def test_handleEvent_event_data_url_containing_social_media_profile_should_return_event(self):sf = SpiderFoot(self.default_options)module = sfp_social()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 = 'SOCIAL_MEDIA'+ if str(event.eventType) != expected:+ raise Exception(f"{event.eventType} != {expected}")++ expected = "LinkedIn (Individual): <SFURL>https://linkedin.com/in/spiderfoot</SFURL>"+ if str(event.data) != expected:+ raise Exception(f"{event.data} != {expected}")++ raise Exception("OK")++ module.notifyListeners = new_notifyListeners.__get__(module, sfp_social)+event_type = 'ROOT'- event_data = 'example data'+ event_data = 'https://linkedin.com/in/spiderfoot'event_module = ''source_event = ''+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_url_not_containing_social_media_profile_should_not_return_event(self):+ sf = SpiderFoot(self.default_options)++ module = sfp_social()+ 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_social)++ event_type = 'ROOT'+ event_data = 'example data'+ event_module = ''+ source_event = ''++ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)result = module.handleEvent(evt)self.assertIsNone(result)