test_dns: handle case where a DNS record is missing (vs incorrect)
This commit is contained in:
parent
d5971e383b
commit
bdadf3017d
1 changed files with 5 additions and 1 deletions
|
@ -42,7 +42,11 @@ def test2(tests, server, description):
|
||||||
resolver.nameservers = [server]
|
resolver.nameservers = [server]
|
||||||
for qname, rtype, expected_answer in tests:
|
for qname, rtype, expected_answer in tests:
|
||||||
# do the query and format the result as a string
|
# do the query and format the result as a string
|
||||||
|
try:
|
||||||
response = dns.resolver.query(qname, rtype)
|
response = dns.resolver.query(qname, rtype)
|
||||||
|
except dns.resolver.NXDOMAIN:
|
||||||
|
# host did not have an answer for this query
|
||||||
|
response = ["NOT SET"]
|
||||||
response = ";".join(str(r) for r in response)
|
response = ";".join(str(r) for r in response)
|
||||||
response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key
|
response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue