Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Tests: test_sfp_webframework: Add handleEvent tests (#1400)

bcoles3f855cbdfaee
diff --git a/test/unit/modules/test_sfp_webframework.py b/test/unit/modules/test_sfp_webframework.py
index 560f35a8..6e45ec36 100644
--- a/test/unit/modules/test_sfp_webframework.py
+++ b/test/unit/modules/test_sfp_webframework.py
@@ -34,7 +34,7 @@ class TestModuleWebFramework(unittest.TestCase):
module = sfp_webframework()
self.assertIsInstance(module.producedEvents(), list)
- def test_handleEvent_domain_whois_event_data_containing_webframework_string_should_create_url_web_framework_event(self):
+ def test_handleEvent_event_data_web_content_containing_webframework_string_should_create_url_web_framework_event(self):
sf = SpiderFoot(self.default_options)
module = sfp_webframework()
@@ -76,7 +76,7 @@ class TestModuleWebFramework(unittest.TestCase):
self.assertEqual("OK", str(cm.exception))
- def test_handleEvent_domain_whois_event_data_not_containing_webframework_string_should_not_create_event(self):
+ def test_handleEvent_event_data_web_content_not_containing_webframework_string_should_not_create_event(self):
sf = SpiderFoot(self.default_options)
module = sfp_webframework()
@@ -108,3 +108,36 @@ class TestModuleWebFramework(unittest.TestCase):
result = module.handleEvent(evt)
self.assertIsNone(result)
+
+ def test_handleEvent_event_data_web_content_from_external_url_containing_webframework_string_should_not_create_event(self):
+ sf = SpiderFoot(self.default_options)
+
+ module = sfp_webframework()
+ 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_webframework)
+
+ event_type = 'ROOT'
+ event_data = 'example data'
+ event_module = ''
+ source_event = ''
+ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
+
+ event_type = 'TARGET_WEB_CONTENT'
+ event_data = 'example data /wp-includes/ example data'
+ event_module = 'sfp_spider'
+ source_event = evt
+ evt = SpiderFootEvent(event_type, event_data, event_module, source_event)
+ evt.actualSource = "https://externalhost.local/"
+
+ result = module.handleEvent(evt)
+
+ self.assertIsNone(result)