Skip to content

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

tests: resolve pep8 violations

Brendan Colese388c972478e
diff --git a/test/unit/test_sf.py b/test/unit/test_sf.py
index ff03f075..1aff8bc4 100644
--- a/test/unit/test_sf.py
+++ b/test/unit/test_sf.py
@@ -1,9 +1,9 @@
# test_sf.py
import unittest
-import io
import sys
import subprocess
+
class TestSf(unittest.TestCase):
"""
Test TestSf
@@ -34,10 +34,10 @@ class TestSf(unittest.TestCase):
def execute(self, command):
proc = subprocess.Popen(
command,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
)
- out,err = proc.communicate()
+ out, err = proc.communicate()
return out, err, proc.returncode
def test_help_arg_should_print_help_and_exit(self):
@@ -94,6 +94,6 @@ class TestSf(unittest.TestCase):
with self.subTest(module=module):
self.assertIn(module.encode(), out)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.py
index 868fdab9..8f8c444a 100644
--- a/test/unit/test_spiderfoot.py
+++ b/test/unit/test_spiderfoot.py
@@ -2,39 +2,40 @@
from sflib import SpiderFoot, SpiderFootTarget
import unittest
+
class TestSpiderFoot(unittest.TestCase):
"""
Test SpiderFoot
"""
default_options = {
- '_debug': False, # Debug
- '__logging': True, # Logging in general
- '__outputfilter': None, # Event types to filter from modules' output
- '__blocknotif': False, # Block notifications
- '_fatalerrors': False,
- '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
- '_dnsserver': '', # Override the default resolver
- '_fetchtimeout': 5, # number of seconds before giving up on a fetch
- '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
- '_internettlds_cache': 72,
- '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.2-DEV',
- '__database': 'spiderfoot.test.db', # note: test database file
- '__webaddr': '127.0.0.1',
- '__webport': 5001,
- '__docroot': '', # don't put trailing /
- '__modules__': None, # List of modules. Will be set after start-up.
- '_socks1type': '',
- '_socks2addr': '',
- '_socks3port': '',
- '_socks4user': '',
- '_socks5pwd': '',
- '_socks6dns': True,
- '_torctlport': 9051,
- '__logstdout': False
+ '_debug': False, # Debug
+ '__logging': True, # Logging in general
+ '__outputfilter': None, # Event types to filter from modules' output
+ '__blocknotif': False, # Block notifications
+ '_fatalerrors': False,
+ '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
+ '_dnsserver': '', # Override the default resolver
+ '_fetchtimeout': 5, # number of seconds before giving up on a fetch
+ '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
+ '_internettlds_cache': 72,
+ '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
+ '__version__': '3.2-DEV',
+ '__database': 'spiderfoot.test.db', # note: test database file
+ '__webaddr': '127.0.0.1',
+ '__webport': 5001,
+ '__docroot': '', # don't put trailing /
+ '__modules__': None, # List of modules. Will be set after start-up.
+ '_socks1type': '',
+ '_socks2addr': '',
+ '_socks3port': '',
+ '_socks4user': '',
+ '_socks5pwd': '',
+ '_socks6dns': True,
+ '_torctlport': 9051,
+ '__logstdout': False
}
-
+
test_tlds = "// ===BEGIN ICANN DOMAINS===\n\ncom\nnet\norg\n\n// // ===END ICANN DOMAINS===\n"
def test_init_argument_options_of_invalid_type_should_raise_TypeError(self):
@@ -45,7 +46,7 @@ class TestSpiderFoot(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sf = SpiderFoot(invalid_type)
+ SpiderFoot(invalid_type)
def test_init_argument_options_with_empty_dict(self):
"""
@@ -166,7 +167,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
with self.assertRaises(BaseException) as cm:
- dblog = sf._dblog(None, None, None)
+ sf._dblog(None, None, None)
def test_error(self):
"""
@@ -264,7 +265,9 @@ class TestSpiderFoot(unittest.TestCase):
label = 'test-cache-label'
data = 'test-cache-data'
- cache_put = sf.cachePut(label, data)
+
+ sf.cachePut(label, data)
+
cache_get = sf.cacheGet(label, sf.opts.get('cacheperiod', 0))
self.assertIsInstance(cache_get, str)
self.assertEqual(data, cache_get)
@@ -276,7 +279,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
with self.assertRaises(TypeError) as cm:
- config = sf.configSerialize(None, None)
+ sf.configSerialize(None, None)
def test_config_serialize_should_return_a_dict(self):
"""
@@ -294,7 +297,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
with self.assertRaises(TypeError) as cm:
- config = sf.configUnserialize(None, dict(), None)
+ sf.configUnserialize(None, dict(), None)
def test_config_unserialize_invalid_reference_point_should_raise(self):
"""
@@ -303,7 +306,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
with self.assertRaises(TypeError) as cm:
- config = sf.configUnserialize(dict(), None, None)
+ sf.configUnserialize(dict(), None, None)
def test_config_unserialize_should_return_a_dict(self):
"""
@@ -425,7 +428,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
base_dir = sf.urlBaseDir('http://localhost.local/path?param=value#fragment')
- self.assertIsInstance( base_dir, str)
+ self.assertIsInstance(base_dir, str)
self.assertEqual('http://localhost.local/', base_dir)
def test_url_base_url_should_return_a_string(self):
@@ -957,7 +960,6 @@ class TestSpiderFoot(unittest.TestCase):
self.assertIsInstance(hashes, list)
self.assertIn("e17cff4eb3e8fbe6ca3b83fb47532dba", hashes)
- #@unittest.skip("todo")
def test_parse_credit_cards_should_return_a_list(self):
"""
Test parseCreditCards(self, data)
@@ -1118,6 +1120,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
pem = sf.sslDerToPem(None)
+ self.assertEqual(pem, None)
+
self.assertEqual('TBD', 'TBD')
def test_ssl_der_to_pem_invalid_cert_should_return_none(self):
@@ -1130,7 +1134,7 @@ class TestSpiderFoot(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- pem = sf.sslDerToPem(invalid_type)
+ sf.sslDerToPem(invalid_type)
def test_parse_cert_should_return_a_dict(self):
"""
@@ -1281,6 +1285,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
data = sf.fetchUrl(None)
+ self.assertEqual(data, None)
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -1340,6 +1346,6 @@ class TestSpiderFoot(unittest.TestCase):
sf.bingIterate(None, None)
self.assertEqual('TBD', 'TBD')
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfoot_module_loading.py b/test/unit/test_spiderfoot_module_loading.py
index 0df2ad9b..92840f23 100644
--- a/test/unit/test_spiderfoot_module_loading.py
+++ b/test/unit/test_spiderfoot_module_loading.py
@@ -1,8 +1,9 @@
# test_spiderfoot_module_loading.py
-from sflib import SpiderFoot, SpiderFootTarget
+from sflib import SpiderFoot
import unittest
import os
+
class TestSpiderFootModuleLoading(unittest.TestCase):
"""
Test SpiderFoot module loading
@@ -10,8 +11,8 @@ class TestSpiderFootModuleLoading(unittest.TestCase):
default_options = {
'_debug': False, # Debug
- '__logging': True, # Logging in general
- '__outputfilter': None, # Event types to filter from modules' output
+ '__logging': True, # Logging in general
+ '__outputfilter': None, # Event types to filter from modules' output
'__blocknotif': False, # Block notifications
'_fatalerrors': False,
'_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
@@ -35,7 +36,7 @@ class TestSpiderFootModuleLoading(unittest.TestCase):
'_torctlport': 9051,
'__logstdout': False
}
-
+
def test_module_loading(self):
"""
Test module loading
@@ -80,10 +81,10 @@ class TestSpiderFootModuleLoading(unittest.TestCase):
self.assertTrue(m.get('object'))
self.assertTrue(m.get('name'))
self.assertTrue(m.get('cats'))
- #self.assertTrue(m.get('group'))
+ # self.assertTrue(m.get('group'))
self.assertTrue(m.get('labels'))
self.assertTrue(m.get('descr'))
- #self.assertTrue(m.get('provides'))
+ # self.assertTrue(m.get('provides'))
self.assertIsInstance(m.get('provides'), list)
self.assertTrue(m.get('consumes'))
self.assertIsInstance(m.get('consumes'), list)
@@ -106,4 +107,3 @@ class TestSpiderFootModuleLoading(unittest.TestCase):
# check len(options) == len(option descriptions)
if m.get('opts'):
self.assertEqual("%s opts: %s" % (module, len(m.get('opts').keys())), "%s opts: %s" % (module, len(m.get('optdescs').keys())))
-
diff --git a/test/unit/test_spiderfootcli.py b/test/unit/test_spiderfootcli.py
index bfe6ac1a..26216abe 100644
--- a/test/unit/test_spiderfootcli.py
+++ b/test/unit/test_spiderfootcli.py
@@ -5,6 +5,7 @@ import io
import sys
import subprocess
+
class TestSpiderFootCli(unittest.TestCase):
"""
Test TestSpiderFootCli
@@ -28,10 +29,10 @@ class TestSpiderFootCli(unittest.TestCase):
def execute(self, command):
proc = subprocess.Popen(
command,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
)
- out,err = proc.communicate()
+ out, err = proc.communicate()
return out, err, proc.returncode
def test_help_arg_should_print_help_and_exit(self):
@@ -102,9 +103,11 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
default = sfcli.complete_default("", "-t -m", None, None)
+ self.assertIsInstance(default, list)
self.assertEqual('TBD', 'TBD')
default = sfcli.complete_default("", "-m -t", None, None)
+ self.assertIsInstance(default, list)
self.assertEqual('TBD', 'TBD')
def test_complete_default_invalid_text_should_return_a_string(self):
@@ -181,7 +184,7 @@ class TestSpiderFootCli(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
- def test_precmd_should_print_line(self):
+ def test_precmd_should_print_line_to_history_file(self):
"""
Test precmd(self, line)
"""
@@ -189,18 +192,14 @@ class TestSpiderFootCli(unittest.TestCase):
line = "example line"
- io_output = io.StringIO()
- sys.stdout = io_output
precmd = sfcli.precmd(line)
- sys.stdout = sys.__stdout__
- output = io_output.getvalue()
self.assertEqual(line, precmd)
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
- def test_precmd_should_return_line(self):
+ def test_precmd_should_print_line_to_spool_file(self):
"""
Test precmd(self, line)
"""
@@ -214,6 +213,19 @@ class TestSpiderFootCli(unittest.TestCase):
self.assertEqual('TBD', 'TBD')
+ @unittest.skip("todo")
+ def test_precmd_should_return_line(self):
+ """
+ Test precmd(self, line)
+ """
+ sfcli = SpiderFootCli()
+
+ line = "example line"
+
+ precmd = sfcli.precmd(line)
+
+ self.assertEqual(line, precmd)
+
@unittest.skip("todo")
def test_ddprint(self):
"""
@@ -302,7 +314,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
parsed_line = sfcli.myparseline("")
-
+
self.assertEqual(len(parsed_line), 2)
self.assertIsInstance(parsed_line, list)
self.assertIsInstance(parsed_line[0], list)
@@ -313,7 +325,7 @@ class TestSpiderFootCli(unittest.TestCase):
Test send_output(self, data, cmd, titles=None, total=True, raw=False)
"""
sfcli = SpiderFootCli()
-
+
io_output = io.StringIO()
sys.stdout = io_output
sfcli.send_output("{}", "", raw=True)
@@ -331,7 +343,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_query(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -341,7 +353,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_ping(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -351,7 +363,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_modules(None, None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -361,7 +373,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_types(None, None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -371,7 +383,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_load(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -381,7 +393,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_scaninfo(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -391,7 +403,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_scans(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -401,7 +413,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_data(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -411,7 +423,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_export(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -421,7 +433,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_logs(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -431,7 +443,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_start(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -441,7 +453,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_stop(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -451,7 +463,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_search(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -461,7 +473,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_find(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -471,7 +483,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_summary(None)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -481,7 +493,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_delete(None)
-
+
self.assertEqual('TBD', 'TBD')
def test_print_topic(self):
@@ -498,7 +510,7 @@ class TestSpiderFootCli(unittest.TestCase):
self.assertIn("Command", output)
self.assertIn("Description", output)
-
+
self.assertEqual('TBD', 'TBD')
@unittest.skip("todo")
@@ -508,7 +520,7 @@ class TestSpiderFootCli(unittest.TestCase):
"""
sfcli = SpiderFootCli()
sfcli.do_set(None)
-
+
self.assertEqual('TBD', 'TBD')
def test_do_shell(self):
@@ -536,7 +548,7 @@ class TestSpiderFootCli(unittest.TestCase):
sfcli.do_clear(None)
sys.stderr = sys.__stderr__
output = io_output.getvalue()
-
+
self.assertEqual("\x1b[2J\x1b[H", output)
def test_do_exit(self):
@@ -555,6 +567,6 @@ class TestSpiderFootCli(unittest.TestCase):
do_eof = sfcli.do_EOF(None)
self.assertTrue(do_eof)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfootdb.py b/test/unit/test_spiderfootdb.py
index 93a1c0ac..e3cbc989 100644
--- a/test/unit/test_spiderfootdb.py
+++ b/test/unit/test_spiderfootdb.py
@@ -2,36 +2,37 @@
from sfdb import SpiderFootDb, SpiderFootEvent
import unittest
+
class TestSpiderFootDb(unittest.TestCase):
"""
Test SpiderFootDb
"""
default_options = {
- '_debug': False,
- '__logging': True,
- '__outputfilter': None,
- '__blocknotif': False,
- '_fatalerrors': False,
- '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
- '_dnsserver': '',
- '_fetchtimeout': 5,
- '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
- '_internettlds_cache': 72,
- '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.2-DEV',
- '__database': 'spiderfoot.test.db', # note: test database file
- '__webaddr': '127.0.0.1',
- '__webport': 5001,
- '__docroot': '',
- '__modules__': None,
- '_socks1type': '',
- '_socks2addr': '',
- '_socks3port': '',
- '_socks4user': '',
- '_socks5pwd': '',
- '_socks6dns': True,
- '_torctlport': 9051,
- '__logstdout': False
+ '_debug': False,
+ '__logging': True,
+ '__outputfilter': None,
+ '__blocknotif': False,
+ '_fatalerrors': False,
+ '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
+ '_dnsserver': '',
+ '_fetchtimeout': 5,
+ '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
+ '_internettlds_cache': 72,
+ '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
+ '__version__': '3.2-DEV',
+ '__database': 'spiderfoot.test.db', # note: test database file
+ '__webaddr': '127.0.0.1',
+ '__webport': 5001,
+ '__docroot': '',
+ '__modules__': None,
+ '_socks1type': '',
+ '_socks2addr': '',
+ '_socks3port': '',
+ '_socks4user': '',
+ '_socks5pwd': '',
+ '_socks6dns': True,
+ '_torctlport': 9051,
+ '__logstdout': False
}
def test_init_argument_opts_of_invalid_type_should_raise_TypeError(self):
@@ -42,14 +43,14 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfdb = SpiderFootDb(invalid_type)
+ SpiderFootDb(invalid_type)
def test_init_argument_opts_with_empty_value_should_raise_ValueError(self):
"""
Test __init__(self, opts, init=False)
"""
with self.assertRaises(ValueError) as cm:
- sfdb = SpiderFootDb(dict())
+ SpiderFootDb(dict())
def test_init_argument_opts_with_empty_key___database_value_should_raise_ValueError(self):
"""
@@ -58,7 +59,7 @@ class TestSpiderFootDb(unittest.TestCase):
with self.assertRaises(ValueError) as cm:
opts = dict()
opts['__database'] = None
- sfdb = SpiderFootDb(opts)
+ SpiderFootDb(opts)
def test_init_should_create_SpiderFootDb_object(self):
"""
@@ -66,7 +67,7 @@ class TestSpiderFootDb(unittest.TestCase):
"""
sfdb = SpiderFootDb(self.default_options, False)
self.assertIsInstance(sfdb, SpiderFootDb)
-
+
@unittest.skip("todo")
def test_create_should_create_database_schema(self):
"""
@@ -110,7 +111,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- search_results = sfdb.search(invalid_type, False)
+ sfdb.search(invalid_type, False)
def test_search_argument_criteria_key_of_invalid_type_should_raise_TypeError(self):
"""
@@ -125,7 +126,7 @@ class TestSpiderFootDb(unittest.TestCase):
}
with self.assertRaises(TypeError) as cm:
- search_results = sfdb.search(criteria, False)
+ sfdb.search(criteria, False)
def test_search_argument_criteria_no_valid_criteria_should_raise_ValueError(self):
"""
@@ -138,7 +139,7 @@ class TestSpiderFootDb(unittest.TestCase):
}
with self.assertRaises(ValueError) as cm:
- search_results = sfdb.search(criteria, False)
+ sfdb.search(criteria, False)
def test_search_argument_criteria_one_criteria_should_raise_ValueError(self):
"""
@@ -151,7 +152,7 @@ class TestSpiderFootDb(unittest.TestCase):
}
with self.assertRaises(ValueError) as cm:
- search_results = sfdb.search(criteria, False)
+ sfdb.search(criteria, False)
def test_eventTypes_should_return_a_list(self):
"""
@@ -311,7 +312,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_instance_set = sfdb.scanInstanceSet(invalid_type, started, ended, status)
+ sfdb.scanInstanceSet(invalid_type, started, ended, status)
def test_scanInstanceGet_should_return_scan_info(self):
"""
@@ -354,7 +355,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_instance_get = sfdb.scanInstanceGet(invalid_type)
+ sfdb.scanInstanceGet(invalid_type)
def test_scanResultSummary_should_return_a_list(self):
"""
@@ -376,7 +377,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_results_summary = sfdb.scanResultSummary(invalid_type)
+ sfdb.scanResultSummary(invalid_type)
def test_scanResultSummary_argument_by_of_invalid_type_should_raise_TypeError(self):
"""
@@ -389,10 +390,10 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_results_summary = sfdb.scanResultSummary(instance_id, invalid_type)
+ sfdb.scanResultSummary(instance_id, invalid_type)
with self.assertRaises(ValueError) as cm:
- scan_results_summary = sfdb.scanResultSummary(instance_id, "invalid filter type")
+ sfdb.scanResultSummary(instance_id, "invalid filter type")
def test_scanResultSummary_argument_by_invalid_value_should_raise_ValueError(self):
"""
@@ -402,7 +403,7 @@ class TestSpiderFootDb(unittest.TestCase):
instance_id = "example instance id"
with self.assertRaises(ValueError) as cm:
- scan_results_summary = sfdb.scanResultSummary(instance_id, "invalid filter type")
+ sfdb.scanResultSummary(instance_id, "invalid filter type")
def test_scanResultEvent_should_return_a_list(self):
"""
@@ -440,7 +441,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_result_event = sfdb.scanResultEvent(instance_id, invalid_type, None)
+ sfdb.scanResultEvent(instance_id, invalid_type, None)
def test_scanResultEventUnique_should_return_a_list(self):
"""
@@ -478,7 +479,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_result_event = sfdb.scanResultEventUnique(instance_id, invalid_type, None)
+ sfdb.scanResultEventUnique(instance_id, invalid_type, None)
def test_scanLogs_should_return_a_list(self):
"""
@@ -536,7 +537,7 @@ class TestSpiderFootDb(unittest.TestCase):
"""
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- scan_instance_delete = sfdb.scanInstanceDelete(instance_id)
+ sfdb.scanInstanceDelete(instance_id)
self.assertEqual('TBD', 'TBD')
@@ -624,7 +625,6 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_result_event = sfdb.scanResultEventUnique("", invalid_type, None)
sfdb.configSet(invalid_type)
def test_configGet_should_return_a_dict(self):
@@ -697,7 +697,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_config = sfdb.scanConfigGet(invalid_type)
+ sfdb.scanConfigGet(invalid_type)
def test_scanEventStore_should_store_a_scan_event(self):
"""
@@ -711,7 +711,7 @@ class TestSpiderFootDb(unittest.TestCase):
source_event = ''
event = SpiderFootEvent(event_type, event_data, module, source_event)
instance_id = "example instance id"
- scan_event_store = sfdb.scanEventStore(instance_id, event)
+ sfdb.scanEventStore(instance_id, event)
def test_scanEventStore_argument_instanceId_of_invalid_type_should_raise_TypeError(self):
"""
@@ -1102,12 +1102,11 @@ class TestSpiderFootDb(unittest.TestCase):
"""
sfdb = SpiderFootDb(self.default_options, False)
- instance_id = "example instance id"
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_result_history = sfdb.scanResultHistory(invalid_type)
+ sfdb.scanResultHistory(invalid_type)
def test_scanElementSourcesDirect_should_return_a_list(self):
"""
@@ -1133,7 +1132,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_sources_direct = sfdb.scanElementSourcesDirect(invalid_type, element_id_list)
+ sfdb.scanElementSourcesDirect(invalid_type, element_id_list)
def test_scanElementSourcesDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
"""
@@ -1146,7 +1145,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_sources_direct = sfdb.scanElementSourcesDirect(instance_id, invalid_type)
+ sfdb.scanElementSourcesDirect(instance_id, invalid_type)
def test_scanElementChildrenDirect_should_return_a_list(self):
"""
@@ -1171,7 +1170,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_children_direct = sfdb.scanElementChildrenDirect(invalid_type, element_id_list)
+ sfdb.scanElementChildrenDirect(invalid_type, element_id_list)
def test_scanElementChildrenDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
"""
@@ -1184,7 +1183,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_children_direct = sfdb.scanElementChildrenDirect(instance_id, invalid_type)
+ sfdb.scanElementChildrenDirect(instance_id, invalid_type)
def test_scanElementSourcesAll_should_return_a_list(self):
"""
@@ -1210,7 +1209,7 @@ class TestSpiderFootDb(unittest.TestCase):
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, child_data)
+ sfdb.scanElementSourcesAll(invalid_type, child_data)
def test_scanElementSourcesAll_argument_childData_of_invalid_type_should_raise_TypeError(self):
"""
@@ -1223,7 +1222,7 @@ class TestSpiderFootDb(unittest.TestCase):
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)
+ sfdb.scanElementSourcesAll(instance_id, invalid_type)
def test_scanElementSourcesAll_argument_childData_with_empty_value_should_raise_ValueError(self):
"""
@@ -1235,7 +1234,7 @@ class TestSpiderFootDb(unittest.TestCase):
child_data = []
with self.assertRaises(ValueError) as cm:
- scan_element_sources_all = sfdb.scanElementSourcesAll(instance_id, child_data)
+ sfdb.scanElementSourcesAll(instance_id, child_data)
def test_scanElementChildrenAll_should_return_a_list(self):
"""
@@ -1260,7 +1259,7 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_children_all = sfdb.scanElementChildrenAll(invalid_type, parent_ids)
+ sfdb.scanElementChildrenAll(invalid_type, parent_ids)
def test_scanElementChildrenAll_argument_parentIds_of_invalid_type_should_raise_TypeError(self):
"""
@@ -1273,8 +1272,8 @@ class TestSpiderFootDb(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- scan_element_children_all = sfdb.scanElementChildrenAll(instance_id, invalid_type)
+ sfdb.scanElementChildrenAll(instance_id, invalid_type)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfootevent.py b/test/unit/test_spiderfootevent.py
index 8f82d5cf..a8255a55 100644
--- a/test/unit/test_spiderfootevent.py
+++ b/test/unit/test_spiderfootevent.py
@@ -2,6 +2,7 @@
from sflib import SpiderFootEvent
import unittest
+
class TestSpiderFootEvent(unittest.TestCase):
"""
Test SpiderFootEvent
@@ -46,12 +47,12 @@ class TestSpiderFootEvent(unittest.TestCase):
source_event = SpiderFootEvent(event_type, event_data, module, source_event)
module = 'example module'
-
+
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(invalid_type, event_data, module, source_event)
+ SpiderFootEvent(invalid_type, event_data, module, source_event)
def test_init_argument_eventType_with_empty_value_should_raise_ValueError(self):
event_type = 'ROOT'
@@ -64,7 +65,7 @@ class TestSpiderFootEvent(unittest.TestCase):
module = 'example module'
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
+ SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_data_of_invalid_type_should_raise_TypeError(self):
"""
@@ -78,7 +79,7 @@ class TestSpiderFootEvent(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, invalid_type, module, source_event)
+ SpiderFootEvent(event_type, invalid_type, module, source_event)
def test_init_argument_data_with_empty_value_should_raise_ValueError(self):
event_type = 'ROOT'
@@ -92,7 +93,7 @@ class TestSpiderFootEvent(unittest.TestCase):
module = 'example module'
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
+ SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_module_of_invalid_type_should_raise_TypeError(self):
"""
@@ -108,7 +109,7 @@ class TestSpiderFootEvent(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, event_data, invalid_type, source_event)
+ SpiderFootEvent(event_type, event_data, invalid_type, source_event)
def test_init_argument_module_with_empty_value_should_raise_ValueError(self):
event_type = 'ROOT'
@@ -122,7 +123,7 @@ class TestSpiderFootEvent(unittest.TestCase):
module = ''
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
+ SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_sourceEvent_of_invalid_type_should_raise_TypeError(self):
"""
@@ -131,7 +132,6 @@ class TestSpiderFootEvent(unittest.TestCase):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
- source_event = SpiderFootEvent(event_type, event_data, module, "ROOT")
event_type = 'example non-root event type'
module = 'example module'
@@ -139,85 +139,79 @@ class TestSpiderFootEvent(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, invalid_type)
+ SpiderFootEvent(event_type, event_data, module, invalid_type)
def test_init_argument_confidence_of_invalid_type_should_raise_TypeError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_type)
+ SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_type)
def test_init_argument_confidence_invalid_value_should_raise_ValueError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_value)
+ SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_value)
def test_init_argument_visibility_of_invalid_type_should_raise_TypeError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_type)
+ SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_type)
def test_init_argument_visibility_invalid_value_should_raise_ValueError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_value)
+ SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_value)
def test_init_argument_risk_of_invalid_type_should_raise_TypeError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_type)
+ SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_type)
def test_init_argument_risk_invalid_value_should_raise_ValueError(self):
event_type = 'ROOT'
event_data = 'example event data'
module = ''
source_event = ''
- evt = SpiderFootEvent(event_type, event_data, module, source_event)
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
with self.assertRaises(ValueError) as cm:
- evt = SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_value)
+ SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_value)
def test_confidence_attribute_should_return_confidence_as_integer(self):
event_type = 'ROOT'
@@ -355,6 +349,6 @@ class TestSpiderFootEvent(unittest.TestCase):
self.assertIsInstance(evt_hash, str)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfootplugin.py b/test/unit/test_spiderfootplugin.py
index 6752f872..b57074e2 100644
--- a/test/unit/test_spiderfootplugin.py
+++ b/test/unit/test_spiderfootplugin.py
@@ -1,40 +1,40 @@
# test_spiderfootplugin.py
-import sflib
-from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent, SpiderFootTarget
+from sflib import SpiderFootPlugin, SpiderFootEvent, SpiderFootTarget
from sfdb import SpiderFootDb
import unittest
+
class TestSpiderFootPlugin(unittest.TestCase):
"""
Test SpiderFoot
"""
default_options = {
- '_debug': False, # Debug
- '__logging': True, # Logging in general
- '__outputfilter': None, # Event types to filter from modules' output
- '__blocknotif': False, # Block notifications
- '_fatalerrors': False,
- '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
- '_dnsserver': '', # Override the default resolver
- '_fetchtimeout': 5, # number of seconds before giving up on a fetch
- '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
- '_internettlds_cache': 72,
- '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.2-DEV',
- '__database': 'spiderfoot.test.db', # note: test database file
- '__webaddr': '127.0.0.1',
- '__webport': 5001,
- '__docroot': '', # don't put trailing /
- '__modules__': None, # List of modules. Will be set after start-up.
- '_socks1type': '',
- '_socks2addr': '',
- '_socks3port': '',
- '_socks4user': '',
- '_socks5pwd': '',
- '_socks6dns': True,
- '_torctlport': 9051,
- '__logstdout': False
+ '_debug': False, # Debug
+ '__logging': True, # Logging in general
+ '__outputfilter': None, # Event types to filter from modules' output
+ '__blocknotif': False, # Block notifications
+ '_fatalerrors': False,
+ '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
+ '_dnsserver': '', # Override the default resolver
+ '_fetchtimeout': 5, # number of seconds before giving up on a fetch
+ '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
+ '_internettlds_cache': 72,
+ '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
+ '__version__': '3.2-DEV',
+ '__database': 'spiderfoot.test.db', # note: test database file
+ '__webaddr': '127.0.0.1',
+ '__webport': 5001,
+ '__docroot': '', # don't put trailing /
+ '__modules__': None, # List of modules. Will be set after start-up.
+ '_socks1type': '',
+ '_socks2addr': '',
+ '_socks3port': '',
+ '_socks4user': '',
+ '_socks5pwd': '',
+ '_socks6dns': True,
+ '_torctlport': 9051,
+ '__logstdout': False
}
def test_init(self):
@@ -149,7 +149,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
sfp = SpiderFootPlugin()
with self.assertRaises(TypeError) as cm:
- scan_id = sfp.getScanId()
+ sfp.getScanId()
def test_get_target_should_return_a_string(self):
"""
@@ -171,7 +171,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
sfp = SpiderFootPlugin()
with self.assertRaises(TypeError) as cm:
- get_target = sfp.getTarget()
+ sfp.getTarget()
def test_register_listener(self):
"""
@@ -219,7 +219,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
event_type = 'ROOT'
event_data = 'test data'
module = 'test module'
- source_event = None #SpiderFootEvent("ROOT", '', '', "ROOT")
+ source_event = None
evt = SpiderFootEvent(event_type, event_data, module, source_event)
sfp.notifyListeners(evt)
@@ -297,6 +297,6 @@ class TestSpiderFootPlugin(unittest.TestCase):
sfp.start()
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfootscanner.py b/test/unit/test_spiderfootscanner.py
index 1c530805..9e1957f9 100644
--- a/test/unit/test_spiderfootscanner.py
+++ b/test/unit/test_spiderfootscanner.py
@@ -3,36 +3,37 @@ from sfscan import SpiderFootScanner
import unittest
import uuid
+
class TestSpiderFootScanner(unittest.TestCase):
"""
Test SpiderFootScanStatus
"""
default_options = {
- '_debug': False,
- '__logging': True,
- '__outputfilter': None,
- '__blocknotif': False,
- '_fatalerrors': False,
- '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
- '_dnsserver': '',
- '_fetchtimeout': 5,
- '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
- '_internettlds_cache': 72,
- '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.2-DEV',
- '__database': 'spiderfoot.test.db', # note: test database file
- '__webaddr': '127.0.0.1',
- '__webport': 5001,
- '__docroot': '',
- '__modules__': None,
- '_socks1type': '',
- '_socks2addr': '',
- '_socks3port': '',
- '_socks4user': '',
- '_socks5pwd': '',
- '_socks6dns': True,
- '_torctlport': 9051,
- '__logstdout': False
+ '_debug': False,
+ '__logging': True,
+ '__outputfilter': None,
+ '__blocknotif': False,
+ '_fatalerrors': False,
+ '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
+ '_dnsserver': '',
+ '_fetchtimeout': 5,
+ '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
+ '_internettlds_cache': 72,
+ '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
+ '__version__': '3.2-DEV',
+ '__database': 'spiderfoot.test.db', # note: test database file
+ '__webaddr': '127.0.0.1',
+ '__webport': 5001,
+ '__docroot': '',
+ '__modules__': None,
+ '_socks1type': '',
+ '_socks2addr': '',
+ '_socks3port': '',
+ '_socks4user': '',
+ '_socks5pwd': '',
+ '_socks6dns': True,
+ '_torctlport': 9051,
+ '__logstdout': False
}
def test_init_argument_start_false_should_create_a_scan_without_starting_the_scan(self):
@@ -69,7 +70,7 @@ class TestSpiderFootScanner(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner(invalid_type, scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner(invalid_type, scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanName_as_empty_string_should_raise_ValueError(self):
"""
@@ -79,7 +80,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = ['sfp__stor_db']
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner("", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanId_of_invalid_type_should_raise_TypeError(self):
"""
@@ -91,7 +92,7 @@ class TestSpiderFootScanner(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner("example scan name", invalid_type, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", invalid_type, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanId_as_empty_string_should_raise_ValueError(self):
"""
@@ -101,7 +102,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = ['sfp__stor_db']
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetValue_of_invalid_type_should_raise_TypeError(self):
"""
@@ -114,7 +115,7 @@ class TestSpiderFootScanner(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, invalid_type, "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, invalid_type, "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetValue_as_empty_string_should_raise_ValueError(self):
"""
@@ -124,7 +125,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = ['sfp__stor_db']
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "", "IP_ADDRESS", module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, "", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetType_of_invalid_type_should_raise_TypeError(self):
"""
@@ -137,7 +138,7 @@ class TestSpiderFootScanner(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", invalid_type, module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", invalid_type, module_list, self.default_options, start=False)
def test_init_argument_targetType_as_empty_string_should_raise_ValueError(self):
"""
@@ -148,20 +149,19 @@ class TestSpiderFootScanner(unittest.TestCase):
target_type = ""
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", target_type, module_list, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", target_type, module_list, self.default_options, start=False)
def test_init_argument_moduleList_of_invalid_type_should_raise_TypeError(self):
"""
Test __init__(self, scanName, scanId, scanTarget, targetType, moduleList, globalOpts)
"""
scan_id = str(uuid.uuid4())
- module_list = ['sfp__stor_db']
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", invalid_type, self.default_options, start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", invalid_type, self.default_options, start=False)
def test_init_argument_moduleList_as_empty_list_should_raise_ValueError(self):
"""
@@ -171,7 +171,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = list()
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
def test_init_argument_globalOpts_of_invalid_type_should_raise_TypeError(self):
"""
@@ -184,7 +184,7 @@ class TestSpiderFootScanner(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, invalid_type, start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, invalid_type, start=False)
def test_init_argument_globalOpts_as_empty_dict_should_raise_ValueError(self):
"""
@@ -194,7 +194,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = ['sfp__stor_db']
with self.assertRaises(ValueError) as cm:
- sfscan = SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
+ SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
def test_attribute_scanId_should_return_scan_id_as_a_string(self):
opts = self.default_options
@@ -221,6 +221,6 @@ class TestSpiderFootScanner(unittest.TestCase):
status = sfscan.status
self.assertIsInstance(status, str)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfoottarget.py b/test/unit/test_spiderfoottarget.py
index 8584f642..b2dba459 100644
--- a/test/unit/test_spiderfoottarget.py
+++ b/test/unit/test_spiderfoottarget.py
@@ -2,6 +2,7 @@
from sflib import SpiderFootTarget
import unittest
+
class TestSpiderFootTarget(unittest.TestCase):
"""
Test SpiderFootTarget
@@ -17,14 +18,14 @@ class TestSpiderFootTarget(unittest.TestCase):
Test __init__(self, targetValue, typeName)
"""
with self.assertRaises(TypeError) as cm:
- target = SpiderFootTarget(None, 'IP_ADDRESS')
+ SpiderFootTarget(None, 'IP_ADDRESS')
def test_init_unsupported_target_type_should_raise(self):
"""
Test __init__(self, targetValue, typeName)
"""
with self.assertRaises(ValueError) as cm:
- target = SpiderFootTarget('example target value', 'example target type')
+ SpiderFootTarget('example target value', 'example target type')
def test_init_supported_target_types(self):
"""
@@ -47,7 +48,7 @@ class TestSpiderFootTarget(unittest.TestCase):
target_type = 'IP_ADDRESS'
target = SpiderFootTarget(target_value, target_type)
- set_alias = target.setAlias(None, None)
+ target.setAlias(None, None)
self.assertEqual('TBD', 'TBD')
def test_target_type_attribute_should_return_a_string(self):
@@ -126,6 +127,6 @@ class TestSpiderFootTarget(unittest.TestCase):
matches = target.matches(None)
self.assertEqual(bool, type(matches))
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/test/unit/test_spiderfootwebui.py b/test/unit/test_spiderfootwebui.py
index 377fbb02..089de25b 100644
--- a/test/unit/test_spiderfootwebui.py
+++ b/test/unit/test_spiderfootwebui.py
@@ -6,13 +6,14 @@ import cherrypy
from cherrypy.test import helper
import os
+
class TestSpiderFootWebUiRoutes(helper.CPWebCase):
@staticmethod
def setup_server():
default_config = {
'_debug': False, # Debug
- '__logging': True, # Logging in general
- '__outputfilter': None, # Event types to filter from modules' output
+ '__logging': True, # Logging in general
+ '__outputfilter': None, # Event types to filter from modules' output
'__blocknotif': False, # Block notifications
'_fatalerrors': False,
'_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0', # User-Agent to use for HTTP requests
@@ -79,7 +80,7 @@ class TestSpiderFootWebUiRoutes(helper.CPWebCase):
cherrypy.tree.mount(SpiderFootWebUi(default_config), default_config['__docroot'], config=conf)
def test_invalid_page_returns_404(self):
- data = self.getPage("/doesnotexist")
+ self.getPage("/doesnotexist")
self.assertStatus('404 Not Found')
def test_static_returns_200(self):
@@ -292,36 +293,37 @@ class TestSpiderFootWebUiRoutes(helper.CPWebCase):
self.assertEqual('TBD', 'TBD')
+
class TestSpiderFootWebUi(unittest.TestCase):
"""
Test SpiderFootWebUi
"""
default_options = {
- '_debug': False,
- '__logging': True,
- '__outputfilter': None,
- '__blocknotif': False,
- '_fatalerrors': False,
- '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
- '_dnsserver': '',
- '_fetchtimeout': 5,
- '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
- '_internettlds_cache': 72,
- '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.2-DEV',
- '__database': 'spiderfoot.test.db', # note: test database file
- '__webaddr': '127.0.0.1',
- '__webport': 5001,
- '__docroot': '',
- '__modules__': None,
- '_socks1type': '',
- '_socks2addr': '',
- '_socks3port': '',
- '_socks4user': '',
- '_socks5pwd': '',
- '_socks6dns': True,
- '_torctlport': 9051,
- '__logstdout': False
+ '_debug': False,
+ '__logging': True,
+ '__outputfilter': None,
+ '__blocknotif': False,
+ '_fatalerrors': False,
+ '_useragent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
+ '_dnsserver': '',
+ '_fetchtimeout': 5,
+ '_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
+ '_internettlds_cache': 72,
+ '_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
+ '__version__': '3.2-DEV',
+ '__database': 'spiderfoot.test.db', # note: test database file
+ '__webaddr': '127.0.0.1',
+ '__webport': 5001,
+ '__docroot': '',
+ '__modules__': None,
+ '_socks1type': '',
+ '_socks2addr': '',
+ '_socks3port': '',
+ '_socks4user': '',
+ '_socks5pwd': '',
+ '_socks6dns': True,
+ '_torctlport': 9051,
+ '__logstdout': False
}
def test_init_no_options_should_raise(self):
@@ -329,10 +331,10 @@ class TestSpiderFootWebUi(unittest.TestCase):
Test __init__(self, config)
"""
with self.assertRaises(TypeError) as cm:
- sfwebui = SpiderFootWebUi(None)
+ SpiderFootWebUi(None)
with self.assertRaises(ValueError) as cm:
- sfwebui = SpiderFootWebUi(dict())
+ SpiderFootWebUi(dict())
@unittest.skip("todo")
def test_init(self):
@@ -341,7 +343,7 @@ class TestSpiderFootWebUi(unittest.TestCase):
"""
sfwebui = SpiderFootWebUi(self.default_options)
self.assertIsInstance(sfwebui, SpiderFootWebUi)
-
+
@unittest.skip("todo")
def test_error_page(self):
"""
@@ -380,7 +382,7 @@ class TestSpiderFootWebUi(unittest.TestCase):
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
with self.assertRaises(TypeError) as cm:
- clean_user_input = sfwebui.cleanUserInput(invalid_type)
+ sfwebui.cleanUserInput(invalid_type)
def test_search_base_should_return_a_list(self):
"""
@@ -771,6 +773,6 @@ class TestSpiderFootWebUi(unittest.TestCase):
scan_element_type_discovery = sfwebui.scanelementtypediscovery(None, None)
self.assertIsInstance(scan_element_type_discovery, str)
+
if __name__ == '__main__':
unittest.main()
-