First few unit tests for target validation
This commit is contained in:
Родитель
631dfdf26f
Коммит
6ed18a9e46
|
@ -16,7 +16,7 @@ coloredlogs.install(level='INFO', logger=logger, reconfigure=True,
|
|||
class Target:
|
||||
|
||||
# Here, tasklist is a list of Task objects
|
||||
def __init__(self, target, results_dict):
|
||||
def __init__(self, target, results_dict={}):
|
||||
self.targetname = target
|
||||
self.targetdomain = ""
|
||||
self.type = ""
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
from lib import target
|
||||
|
||||
|
||||
class TestTarget(object):
|
||||
def test_URLtarget(self):
|
||||
fqdnurl = "https://www.mozilla.org"
|
||||
ipv4url = "http://10.10.10.10"
|
||||
assert (target.Target(fqdnurl).isValid() and
|
||||
target.Target(ipv4url).isValid())
|
||||
|
||||
def test_IPv4Target(self):
|
||||
ipv4 = "10.10.10.10"
|
||||
assert target.Target(ipv4).valid_ip()
|
||||
|
||||
def test_FQDNTarget(self):
|
||||
fqdn = "www.mozilla.org"
|
||||
assert target.Target(fqdn).valid_fqdn()
|
||||
|
||||
def test_InvalidTarget(self):
|
||||
bad_pattern = "192.168.1.1"
|
||||
assert not target.Target(bad_pattern).isValid()
|
||||
|
||||
bad_scheme = "ssh://10.10.10.10"
|
||||
assert not target.Target(bad_scheme).isValid()
|
||||
|
||||
badIPv4 = "300.200.100.1"
|
||||
assert not target.Target(badIPv4).isValid()
|
||||
|
||||
bad_domain = "sodiajdoaijwo"
|
||||
assert not target.Target(bad_domain).isValid()
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче