Skip to content

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

tests: update test_spiderfoot

Brendan Coles9fb19b920336
diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.py
index fc1f3939..e47c604b 100644
--- a/test/unit/test_spiderfoot.py
+++ b/test/unit/test_spiderfoot.py
@@ -1,5 +1,5 @@
# test_spiderfoot.py
-from sflib import SpiderFoot
+from sflib import SpiderFoot, SpiderFootTarget
import unittest
class TestSpiderFoot(unittest.TestCase):
@@ -79,19 +79,24 @@ class TestSpiderFoot(unittest.TestCase):
"""
Test optValueToData(self, val, fatal=True, splitLines=True)
"""
- sf = SpiderFoot(dict())
+ sf = SpiderFoot(self.default_options)
- sf.optValueToData(None)
- self.assertEqual('TBD', 'TBD')
+ test_string = "example string"
+ opt_data = sf.optValueToData(test_string, fatal=True, splitLines=True)
+ self.assertIsInstance(opt_data, str)
+ self.assertEqual(test_string, opt_data)
- def test_opt_value_to_data_no_value_should_return_none(self):
+ def test_opt_value_to_data_invalid_opt_should_return_none(self):
"""
Test optValueToData(self, val, fatal=True, splitLines=True)
"""
sf = SpiderFoot(self.default_options)
- res = sf.optValueToData(None)
- self.assertEqual(None, res)
+ opt_data = sf.optValueToData(None, fatal=True, splitLines=True)
+ self.assertEqual(None, opt_data)
+
+ opt_data = sf.optValueToData([], fatal=True, splitLines=True)
+ self.assertEqual(None, opt_data)
def test_build_graph_data_should_return_a_set(self):
"""
@@ -100,7 +105,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
graph_data = sf.buildGraphData('')
- self.assertEqual(set, type(graph_data))
+ self.assertIsInstance(graph_data, set)
def test_build_graph_gexf_should_return_bytes(self):
"""
@@ -109,7 +114,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
gexf = sf.buildGraphGexf('', '', '')
- self.assertEqual(bytes, type(gexf))
+ self.assertIsInstance(gexf, bytes)
def test_build_graph_json_should_return_a_string(self):
"""
@@ -118,7 +123,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
json = sf.buildGraphJson('', '')
- self.assertEqual(str, type(json))
+ self.assertIsInstance(json, str)
def test_set_dbh(self):
"""
@@ -145,23 +150,34 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
scan_instance_id = sf.genScanInstanceGUID(None)
- self.assertEqual(str, type(scan_instance_id))
+ self.assertIsInstance(scan_instance_id, str)
def test_dblog(self):
"""
Test _dblog(self, level, message, component=None)
"""
+ sf = SpiderFoot(dict())
+
self.assertEqual('TBD', 'TBD')
+ dblog = sf._dblog("", "", "")
+ self.assertTrue(dblog)
+
+ dblog = sf._dblog(None, None, None)
+ self.assertTrue(dblog)
+
def test_error(self):
"""
Test error(self, error, exception=True)
"""
sf = SpiderFoot(self.default_options)
- sf.error('', exception=False)
+ sf.error(None, exception=False)
self.assertEqual('TBD', 'TBD')
+ with self.assertRaises(BaseException) as cm:
+ sf.error(None, exception=True)
+
def test_fatal_should_exit(self):
"""
Test fatal(self, error)
@@ -207,7 +223,16 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
path = sf.myPath()
- self.assertEqual(str, type(path))
+ self.assertIsInstance(path, str)
+
+ def test_data_path_should_return_a_string(self):
+ """
+ Test def dataPath(self)
+ """
+ sf = SpiderFoot(dict())
+
+ path = sf.myPath()
+ self.assertIsInstance(path, str)
def test_hash_string_should_return_a_string(self):
"""
@@ -216,7 +241,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
hash_string = sf.hashstring('example string')
- self.assertEqual(str, type(hash_string))
+ self.assertIsInstance(hash_string, str)
+ self.assertEqual("aedfb92b3053a21a114f4f301a02a3c6ad5dff504d124dc2cee6117623eec706", hash_string)
def test_cache_path_should_return_a_string(self):
"""
@@ -225,7 +251,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
cache_path = sf.cachePath()
- self.assertEqual(str, type(cache_path))
+ self.assertIsInstance(cache_path, str)
def test_cache_get_should_return_a_string(self):
"""
@@ -238,7 +264,7 @@ class TestSpiderFoot(unittest.TestCase):
data = 'test-cache-data'
cache_put = sf.cachePut(label, data)
cache_get = sf.cacheGet(label, sf.opts.get('cacheperiod', 0))
- self.assertEqual(str, type(cache_get))
+ self.assertIsInstance(cache_get, str)
self.assertEqual(data, cache_get)
def test_cache_get_invalid_label_should_return_none(self):
@@ -275,31 +301,78 @@ class TestSpiderFoot(unittest.TestCase):
"""
Test targetType(self, target)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ target_type = sf.targetType("0.0.0.0")
+ self.assertEqual('IP_ADDRESS', target_type)
+ target_type = sf.targetType("[email protected]")
+ self.assertEqual('EMAILADDR', target_type)
+ target_type = sf.targetType("0.0.0.0/0")
+ self.assertEqual('NETBLOCK_OWNER', target_type)
+ target_type = sf.targetType("+1234567890")
+ self.assertEqual('PHONE_NUMBER', target_type)
+ target_type = sf.targetType('"Human Name"')
+ self.assertEqual('HUMAN_NAME', target_type)
+ target_type = sf.targetType('"abc123"')
+ self.assertEqual('USERNAME', target_type)
+ target_type = sf.targetType("1234567890")
+ self.assertEqual('BGP_AS_OWNER', target_type)
+ target_type = sf.targetType("::1")
+ self.assertEqual('IPV6_ADDRESS', target_type)
+ target_type = sf.targetType("spiderfoot.net")
+ self.assertEqual('INTERNET_NAME', target_type)
+
+ def test_target_type_invalid_seed_should_return_none(self):
+ """
+ Test targetType(self, target)
+ """
+ sf = SpiderFoot(dict())
+
+ target_type = sf.targetType(None)
+ self.assertEqual(None, target_type)
+
+ target_type = sf.targetType("")
+ self.assertEqual(None, target_type)
+
+ target_type = sf.targetType('""')
+ self.assertEqual(None, target_type)
+
def test_modules_producing(self):
"""
Test modulesProducing(self, events)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ modules_producing = sf.modulesProducing(list())
+ self.assertIsInstance(modules_producing, list)
def test_modules_consuming(self):
"""
Test modulesConsuming(self, events)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ modules_consuming = sf.modulesConsuming(list())
+ self.assertIsInstance(modules_consuming, list)
def test_events_from_modules(self):
"""
Test eventsFromModules(self, modules)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ events_from_modules = sf.eventsFromModules(list())
+ self.assertIsInstance(events_from_modules, list)
def test_events_to_modules(self):
"""
Test eventsToModules(self, modules)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ events_to_modules = sf.eventsToModules(list())
+ self.assertIsInstance(events_to_modules, list)
def test_url_relative_to_absolute_should_return_a_string(self):
"""
@@ -307,8 +380,9 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- relative_url = sf.urlRelativeToAbsolute('http://localhost.local/path')
- self.assertEqual(str, type(relative_url))
+ relative_url = sf.urlRelativeToAbsolute('/somewhere/else/../../path?param=value#fragment')
+ self.assertIsInstance(relative_url, str)
+ self.assertEqual('/path?param=value#fragment', relative_url)
def test_url_base_dir_should_return_a_string(self):
"""
@@ -316,8 +390,9 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- base_dir = sf.urlBaseDir('http://localhost.local/path')
- self.assertEqual(str, type(base_dir))
+ base_dir = sf.urlBaseDir('http://localhost.local/path?param=value#fragment')
+ self.assertIsInstance( base_dir, str)
+ self.assertEqual('http://localhost.local/', base_dir)
def test_url_base_url_should_return_a_string(self):
"""
@@ -325,8 +400,9 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- base_url = sf.urlBaseUrl('http://localhost.local/path')
- self.assertEqual(str, type(base_url))
+ base_url = sf.urlBaseUrl('http://localhost.local/path?param=value#fragment')
+ self.assertIsInstance(base_url, str)
+ self.assertEqual('http://localhost.local', base_url)
def test_url_fqdn_should_return_a_string(self):
"""
@@ -335,7 +411,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
fqdn = sf.urlFQDN('http://localhost.local')
- self.assertEqual(str, type(fqdn))
+ self.assertIsInstance(fqdn, str)
+ self.assertEqual("localhost.local", fqdn)
def test_domain_keyword_should_return_a_string(self):
"""
@@ -344,7 +421,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
keyword = sf.domainKeyword('www.spiderfoot.net', sf.opts.get('_internettlds'))
- self.assertEqual(str, type(keyword))
+ self.assertIsInstance(keyword, str)
self.assertEqual('wwwspiderfootnet', keyword)
def test_domain_keyword_invalid_domain_should_return_none(self):
@@ -368,7 +445,9 @@ class TestSpiderFoot(unittest.TestCase):
domain_list = ['www.example.com', 'localhost.local']
keywords = sf.domainKeywords(domain_list, sf.opts.get('_internettlds'))
- self.assertEqual(set, type(keywords))
+ self.assertIsInstance(keywords, set)
+ self.assertIn('localhostlocal', keywords)
+ self.assertIn('wwwexamplecom', keywords)
def test_domain_keywords_invalid_domainlist_should_return_a_set(self):
"""
@@ -377,11 +456,11 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
keywords = sf.domainKeywords("", sf.opts.get('_internettlds'))
- self.assertEqual(set, type(keywords))
+ self.assertIsInstance(keywords, set)
keywords = sf.domainKeywords([], sf.opts.get('_internettlds'))
- self.assertEqual(set, type(keywords))
+ self.assertIsInstance(keywords, set)
keywords = sf.domainKeywords(None, sf.opts.get('_internettlds'))
- self.assertEqual(set, type(keywords))
+ self.assertIsInstance(keywords, set)
def test_host_domain_invalid_host_should_return_none(self):
"""
@@ -399,15 +478,15 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
host_domain = sf.hostDomain('local', sf.opts.get('_internettlds'))
- self.assertEqual(str, type(host_domain))
+ self.assertIsInstance(host_domain, str)
self.assertEqual('local', host_domain)
host_domain = sf.hostDomain('spiderfoot.net', sf.opts.get('_internettlds'))
- self.assertEqual(str, type(host_domain))
+ self.assertIsInstance(host_domain, str)
self.assertEqual('net', host_domain)
host_domain = sf.hostDomain('www.spiderfoot.net', sf.opts.get('_internettlds'))
- self.assertEqual(str, type(host_domain))
+ self.assertIsInstance(host_domain, str)
self.assertEqual('net', host_domain)
def test_host_domain_invalid_tldlist_should_return_none(self):
@@ -425,8 +504,19 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(self.default_options)
- is_domain = sf.isDomain('local', None)
- self.assertEqual(bool, type(is_domain))
+ is_domain = sf.isDomain('local', sf.opts.get('_internettlds'))
+ self.assertIsInstance(is_domain, bool)
+ self.assertTrue(is_domain)
+
+ def test_is_domain_invalid_tldlist_should_return_false(self):
+ """
+ Test isDomain(self, hostname, tldList)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ is_domain = sf.isDomain('spiderfoot.net', None)
+ self.assertIsInstance(is_domain, bool)
+ self.assertFalse(is_domain)
def test_valid_ip_should_return_a_boolean(self):
"""
@@ -435,7 +525,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
valid_ip = sf.validIP('0.0.0.0')
- self.assertEqual(bool, type(valid_ip))
+ self.assertIsInstance(valid_ip, bool)
+ self.assertTrue(valid_ip)
def test_valid_ip6_should_return_a_boolean(self):
"""
@@ -444,7 +535,8 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
valid_ip6 = sf.validIP6('::1')
- self.assertEqual(bool, type(valid_ip6))
+ self.assertIsInstance(valid_ip6, bool)
+ self.assertTrue(valid_ip6)
def test_valid_ip_network_should_return_a_boolean(self):
"""
@@ -453,19 +545,56 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
valid_ip_network = sf.validIpNetwork('0.0.0.0/0')
- self.assertEqual(bool, type(valid_ip_network))
+ self.assertIsInstance(valid_ip_network, bool)
- def tes_normalize_dns(self):
+ def test_normalize_dns(self):
"""
Test normalizeDNS(self, res)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ dns = sf.normalizeDNS(["example.local.", ["spiderfoot.net."]])
+ self.assertIsInstance(dns, list)
+ self.assertIn("example.local", dns)
+ self.assertIn("spiderfoot.net", dns)
+
+ def test_normalize_dns_should_return_list(self):
+ """
+ Test normalizeDNS(self, res)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ dns = sf.normalizeDNS(None)
+ self.assertIsInstance(dns, list)
+
+ dns = sf.normalizeDNS([])
+ self.assertIsInstance(dns, list)
def test_sanitise_input(self):
"""
Test sanitiseInput(self, cmd)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ safe = sf.sanitiseInput("example-string")
+ self.assertIsInstance(safe, bool)
+ self.assertTrue(safe)
+
+ safe = sf.sanitiseInput("example-string\n")
+ self.assertIsInstance(safe, bool)
+ self.assertFalse(safe)
+
+ safe = sf.sanitiseInput("example string")
+ self.assertIsInstance(safe, bool)
+ self.assertFalse(safe)
+
+ safe = sf.sanitiseInput("-example string")
+ self.assertIsInstance(safe, bool)
+ self.assertFalse(safe)
+
+ safe = sf.sanitiseInput(".. example string")
+ self.assertIsInstance(safe, bool)
+ self.assertFalse(safe)
def test_dictwords_should_return_a_list(self):
"""
@@ -474,7 +603,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
dict_words = sf.dictwords()
- self.assertEqual(list, type(dict_words))
+ self.assertIsInstance(dict_words, list)
def test_dictnames_should_return_a_list(self):
"""
@@ -483,79 +612,192 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(dict())
dict_names = sf.dictnames()
- self.assertEqual(list, type(dict_names))
+ self.assertIsInstance(dict_names, list)
- def test_data_parent_child_to_tree(self):
+ def test_data_parent_child_to_tree_should_return_dict(self):
"""
Test dataParentChildToTree(self, data)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(dict())
+
+ tree = sf.dataParentChildToTree(None)
+ self.assertIsInstance(tree, dict)
+
+ tree = sf.dataParentChildToTree([])
+ self.assertIsInstance(tree, dict)
+
+ tree = sf.dataParentChildToTree("")
+ self.assertIsInstance(tree, dict)
def test_resolve_host(self):
"""
Test resolveHost(self, host)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ addrs = sf.resolveHost('spiderfoot.net')
+ self.assertIsInstance(addrs, list)
+ self.assertTrue(addrs)
+
+ def test_resolve_host_invalid_host_should_return_none(self):
+ """
+ Test resolveHost(self, host)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ addrs = sf.resolveHost(None)
+ self.assertEqual(None, addrs)
def test_resolve_ip(self):
"""
Test resolveIP(self, ipaddr)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ addrs = sf.resolveIP('spiderfoot.net')
+ self.assertIsInstance(addrs, list)
+ self.assertTrue(addrs)
+
+ def test_resolve_ip_invalid_ip_should_return_none(self):
+ """
+ Test resolveIP(self, ipaddr)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ addrs = sf.resolveIP(None)
+ self.assertEqual(None, addrs)
def test_resolve_host6(self):
"""
Test resolveHost6(self, hostname)
"""
+ sf = SpiderFoot(self.default_options)
+
self.assertEqual('TBD', 'TBD')
- def test_validate_ip(self):
+ def test_validate_ip_should_return_bool(self):
"""
Test validateIP(self, host, ip)
"""
+ sf = SpiderFoot(self.default_options)
+
+ validate_ip = sf.validateIP(None, None)
+ self.assertIsInstance(validate_ip, bool)
+ self.assertEqual(False, validate_ip)
+
self.assertEqual('TBD', 'TBD')
- def test_resolve_targets(self):
+ def test_resolve_targets_should_return_list(self):
"""
Test resolveTargets(self, target, validateReverse)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ target = SpiderFootTarget("spiderfoot.net", "INTERNET_NAME")
+ resolve_targets = sf.resolveTargets(target, False)
+ self.assertIsInstance(resolve_targets, list)
+ self.assertIn('spiderfoot.net', resolve_targets)
def test_safe_socket(self):
"""
Test safeSocket(self, host, port, timeout)
"""
+ sf = SpiderFoot(self.default_options)
+
self.assertEqual('TBD', 'TBD')
def test_safe_ssl_socket(self):
"""
Test safeSSLSocket(self, host, port, timeout)
"""
+ sf = SpiderFoot(self.default_options)
+
self.assertEqual('TBD', 'TBD')
- def test_parse_robots_txt(self):
+ def test_parse_robots_txt_should_return_list(self):
"""
Test parseRobotsTxt(self, robotsTxtData)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ robots_txt = sf.parseRobotsTxt(None)
+ self.assertIsInstance(robots_txt, list)
- def test_parse_emails(self):
+ def test_parse_emails_should_return_list(self):
"""
Test parseEmails(self, data)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ parse_emails = sf.parseEmails("<html><body><p>From:[email protected]</p><p>Subject:Hello [email protected], here's some text</p></body></html>")
+ self.assertIsInstance(parse_emails, list)
+ self.assertIn('[email protected]', parse_emails)
+ self.assertIn('[email protected]', parse_emails)
+
+ def test_parse_emails_invalid_data_should_return_list(self):
+ """
+ Test parseEmails(self, data)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ parse_emails = sf.parseEmails(None)
+ self.assertIsInstance(parse_emails, list)
def test_ssl_der_to_pem(self):
"""
Test sslDerToPem(self, der)
"""
+ sf = SpiderFoot(self.default_options)
+
self.assertEqual('TBD', 'TBD')
- def test_parse_cert(self):
+ def test_ssl_der_to_pem_invalid_cert_should_return_none(self):
+ """
+ Test sslDerToPem(self, der)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ pem = sf.sslDerToPem(None)
+ self.assertEqual(None, pem)
+
+ pem = sf.sslDerToPem("")
+ self.assertEqual(None, pem)
+
+ def test_parse_cert_should_return_a_dict(self):
"""
Test parseCert(self, rawcert, fqdn=None, expiringdays=30)
"""
- self.assertEqual('TBD', 'TBD')
+ sf = SpiderFoot(self.default_options)
+
+ parse_cert = sf.parseCert("-----BEGIN CERTIFICATE-----\nMIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0NlowSjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMTGkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EFq6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWAa6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIGCCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNvbTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9kc3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAwVAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcCARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAzMDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwuY3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsFAAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJouM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwuX4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlGPfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==\n-----END CERTIFICATE-----")
+ self.assertIsInstance(parse_cert, dict)
+
+ def test_parse_cert_invalid_cert_should_return_none(self):
+ """
+ Test parseCert(self, rawcert, fqdn=None, expiringdays=30)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ parse_cert = sf.parseCert(None, 'spiderfoot.net', 30)
+ self.assertEqual(None, parse_cert)
+
+ def test_parse_cert_invalid_fqdn_should_return_none(self):
+ """
+ Test parseCert(self, rawcert, fqdn=None, expiringdays=30)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ parse_cert = sf.parseCert(None, None, 30)
+ self.assertEqual(None, parse_cert)
+
+ def test_parse_cert_invalid_expiringdays_should_return_none(self):
+ """
+ Test parseCert(self, rawcert, fqdn=None, expiringdays=30)
+ """
+ sf = SpiderFoot(self.default_options)
+
+ parse_cert = sf.parseCert(None, 'spiderfoot.net', None)
+ self.assertEqual(None, parse_cert)
def test_parse_links_should_return_a_dict(self):
"""
@@ -564,7 +806,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
parse_links = sf.parseLinks('url', 'data', 'domains')
- self.assertEqual(dict, type(parse_links))
+ self.assertIsInstance(parse_links, dict)
def test_parse_links_invalid_url_should_return_a_dict(self):
"""
@@ -573,7 +815,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
parse_links = sf.parseLinks(None, 'data', 'domains')
- self.assertEqual(dict, type(parse_links))
+ self.assertIsInstance(parse_links, dict)
def test_parse_links_invalid_data_should_return_a_dict(self):
"""
@@ -582,7 +824,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
parse_links = sf.parseLinks('url', None, 'domains')
- self.assertEqual(dict, type(parse_links))
+ self.assertIsInstance(parse_links, dict)
def test_parse_links_invalid_domains_should_return_a_dict(self):
"""
@@ -600,7 +842,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
url_encode_unicode = sf.urlEncodeUnicode('url')
- self.assertEqual(str, type(url_encode_unicode))
+ self.assertIsInstance(url_encode_unicode, str)
def test_fetch_url(self):
"""
@@ -630,7 +872,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
check_dns_wildcard = sf.checkDnsWildcard(None)
- self.assertEqual(bool, type(check_dns_wildcard))
+ self.assertIsInstance(check_dns_wildcard, bool)
def test_check_dns_wildcard_should_return_a_boolean(self):
"""
@@ -639,7 +881,7 @@ class TestSpiderFoot(unittest.TestCase):
sf = SpiderFoot(self.default_options)
check_dns_wildcard = sf.checkDnsWildcard('local')
- self.assertEqual(bool, type(check_dns_wildcard))
+ self.assertIsInstance(check_dns_wildcard, bool)
def test_google_iterate(self):
"""