Repository: smicallef/spiderfoot
File: test/unit/modules/test_sfp_base64.py (Python)

Code before:
        '_torctlport': 9051,
        '__logstdout': False
    }

    def test_opts(self):
        module = sfp_base64()
        self.assertEqual(len(module.opts), len(module.optdescs))

    def test_setup(self):
        """
        Test setup(self, sfc, userOpts=dict())
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_base64()
        module.setup(sf, dict())

    def test_watchedEvents_should_return_list(self):
        module = sfp_base64()
        self.assertIsInstance(module.watchedEvents(), list)

    def test_producedEvents_should_return_list(self):
        module = sfp_base64()
        self.assertIsInstance(module.producedEvents(), list)

    def test_handleEvent_url_containing_base64_string_should_return_event(self):
        sf = SpiderFoot(self.default_options)

        module = sfp_base64()
        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):
            expected = 'BASE64_DATA'
            if str(event.eventType) != expected:
                raise Exception(f"{event.eventType} != {expected}")

            expected = "U3BpZGVyRm9vdA== (SpiderFoot)"
            if str(event.data) != expected:
                raise Exception(f"{event.data} != {expected}")

        module.notifyListeners = new_notifyListeners.__get__(module, sfp_base64)

        event_type = 'ROOT'
        event_data = 'https://someurl/?somevar=U3BpZGVyRm9vdA== example data'
        event_module = ''
        source_event = ''

Review comment (suggestion):
```suggestion
    def test_handleEvent_event_data_url_containing_base64_string_should_return_event(self):
```

Code after:
        '_torctlport': 9051,
        '__logstdout': False
    }

    def test_opts(self):
        module = sfp_base64()
        self.assertEqual(len(module.opts), len(module.optdescs))

    def test_setup(self):
        """
        Test setup(self, sfc, userOpts=dict())
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_base64()
        module.setup(sf, dict())

    def test_watchedEvents_should_return_list(self):
        module = sfp_base64()
        self.assertIsInstance(module.watchedEvents(), list)

    def test_producedEvents_should_return_list(self):
        module = sfp_base64()
        self.assertIsInstance(module.producedEvents(), list)

    def test_handleEvent_event_data_url_containing_base64_string_should_return_event(self):
        sf = SpiderFoot(self.default_options)

        module = sfp_base64()
        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):
            expected = 'BASE64_DATA'
            if str(event.eventType) != expected:
                raise Exception(f"{event.eventType} != {expected}")

            expected = "U3BpZGVyRm9vdA== (SpiderFoot)"
            if str(event.data) != expected:
                raise Exception(f"{event.data} != {expected}")

        module.notifyListeners = new_notifyListeners.__get__(module, sfp_base64)

        event_type = 'ROOT'
        event_data = 'https://someurl/?somevar=example%20data%20U3BpZGVyRm9vdA%3d%3d%20example%20data'
        event_module = ''
        source_event = ''