diff --git a/dnsverify.py b/dnsverify.py index 39854ab..19dddf9 100644 --- a/dnsverify.py +++ b/dnsverify.py @@ -15,21 +15,21 @@ from dns import resolver # list of puzzle authoritative name servers pitc_nameservers = [ - 'ns1.dnsimple.com.', - 'ns2.dnsimple.com.', - 'ns3.dnsimple.com.', - 'ns4.dnsimple.com.', - 'ns5.dnsmadeeasy.com.', - 'ns6.dnsmadeeasy.com.', - 'ns7.dnsmadeeasy.com.' - ] + 'ns1.dnsimple.com.', + 'ns2.dnsimple.com.', + 'ns3.dnsimple.com.', + 'ns4.dnsimple.com.', + 'ns5.dnsmadeeasy.com.', + 'ns6.dnsmadeeasy.com.', + 'ns7.dnsmadeeasy.com.' +] # list of puzzle managed zone files pitc_domains = [ - 'puzzle.ch.yaml', - 'puzzle.yaml', - 'nonpuzzle.yaml' - ] + 'puzzle.ch.yaml', + 'puzzle.yaml', + 'nonpuzzle.yaml' +] # configure opendns resolver resolver = resolver.Resolver() @@ -37,13 +37,13 @@ resolver.nameservers = ['208.67.222.222','208.67.220.220'] def do_check(domains, nameservers, verbose=False): ''' - dsc: Implementatin of the check loop which writes output if verbose is set. - Checks if the authoritative ns returned for domain x is in the list - of nameservers provided as argument. - arg: [list], domains to check - arg: [list], verified nameservers - arg: [boolean], verbose printing or not - ret: [boolean], true if all checked nameservers are ok, false otherwise + dsc: Implementatin of the check loop which writes output if verbose is set. + Checks if the authoritative ns returned for domain x is in the list + of nameservers provided as argument. + arg: [list], domains to check + arg: [list], verified nameservers + arg: [boolean], verbose printing or not + ret: [boolean], true if all checked nameservers are ok, false otherwise ''' for domain in domains: returned_nameservers = get_authoritative_ns(domain) @@ -63,9 +63,9 @@ def do_check(domains, nameservers, verbose=False): def get_authoritative_ns(domain): ''' - dsc: Query the domain and return the authoritative name servers. - arg: [str], domain to query - ret: [list], list of nameservers or empty list on error. + dsc: Query the domain and return the authoritative name servers. + arg: [str], domain to query + ret: [list], list of nameservers or empty list on error. ''' try: answer = resolver.resolve(domain,'NS') @@ -78,9 +78,9 @@ def get_authoritative_ns(domain): def get_domains_from_yaml(filenames): ''' - dsc: Loads domain names from a list of yaml files. - arg: [list], filenames - ret: [list], arbitrary list of domain names, emptylist on err + dsc: Loads domain names from a list of yaml files. + arg: [list], filenames + ret: [list], arbitrary list of domain names, emptylist on err ''' domains = [] try: @@ -97,10 +97,10 @@ def get_domains_from_yaml(filenames): def verify_authoritative_ns(nameserver, verified_nameservers): ''' - dsc: Verifies if the authoritative NS belongs to the puzzle managed NS. - arg: [str], nameserver to test - arg: [list], a list of verified nameservers - ret: [boolean], true if ok; false if nok. + dsc: Verifies if the authoritative NS belongs to the puzzle managed NS. + arg: [str], nameserver to test + arg: [list], a list of verified nameservers + ret: [boolean], true if ok; false if nok. ''' if not isinstance(nameserver, str): print("Type of nameserver must be string!") diff --git a/test_dnsverify.py b/dnsverify_tests.py similarity index 78% rename from test_dnsverify.py rename to dnsverify_tests.py index 544db76..676da38 100644 --- a/test_dnsverify.py +++ b/dnsverify_tests.py @@ -16,23 +16,23 @@ from pylint.reporters import CollectingReporter class TestDnsVerify(unittest.TestCase): def test_do_check(self): ''' - ... Test if checks acutally fail when an error occures. + ... Test whether checks acutally fail when an error occures. ''' self.assertEqual(do_check(['puzzle.ch'], ['ns1.google.com'], verbose=False), False) def test_get_authoritative_ns(self): ''' - ... Test if garbage queries trigger a stack trace. + ... Test whether garbage queries trigger a stack trace. ''' self.assertEqual(get_authoritative_ns('dinimer.lolwas'), []) def test_get_domains_from_yaml(self): ''' - ... Test wheter missing files generate an empty list. + ... Test whether missing files generate an empty list. ''' self.assertEqual(get_domains_from_yaml(["notexist.yaml"]), []) def test_verify_authoritative_ns(self): ''' - ... Test wheter false is returned when the ns does not match the list. And test if type errors are handeled correctly. + ... Test whether false if check fails and test if type errors are handeled correctly. ''' self.assertEqual(verify_authoritative_ns('ns1.google.com', ['ns2.google.com']), False) self.assertRaises(TypeError, verify_authoritative_ns, 123, ['123']) @@ -40,7 +40,7 @@ class TestDnsVerify(unittest.TestCase): def test_pylint(self): ''' - ... Test wheter the coding style is acceptable. + ... Test whether the coding style is acceptable. ''' rep = CollectingReporter() results = Run(['dnsverify.py', '-sn'], reporter=rep, exit=False) diff --git a/run_tests.sh b/run_tests.sh index 1fd30a2..e0ac902 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,3 +1,3 @@ #!/bin/env bash -pipenv run python -m unittest -bv test_dnsverify +pipenv run python -m unittest -bv dnsverify_tests.py