Commit 98a22c01 authored by Alexandre's avatar Alexandre
Browse files

Merge branch 'fix-monitoring_tests' into option-check

parents 93e1d034 39dda3fa
......@@ -175,6 +175,10 @@ def validate_hostname(hostname, cert):
return False
class CustomException(Exception):
pass
class Request:
def __init__(self, qname, qtype=rtype, use_edns=edns, want_dnssec=dnssec):
self.message = dns.message.make_query(qname, dns.rdatatype.from_text(qtype), use_edns=use_edns, want_dnssec=want_dnssec)
......@@ -238,7 +242,7 @@ class Connection:
if not dot and not is_valid_url(url):
error("DoH requires a valid HTTPS URL, not \"%s\"" % server)
if forceIPv4 and forceIPv6:
raise Exception("Force IPv4 *or* IPv6 but not both")
raise CustomException("Force IPv4 *or* IPv6 but not both")
self.server = server
self.servername = servername
if self.servername is not None:
......@@ -255,11 +259,11 @@ class Connection:
def check_ip_address(self, addr):
(is_addr, self.family) = is_valid_ip_address(addr)
if not is_addr and not self.dot:
raise Exception("%s is not IPv4 and not IPv6" % addr)
raise CustomException("%s is not IPv4 and not IPv6" % addr)
if forceIPv4 and self.family == 6:
raise Exception("You cannot force IPv4 with a litteral IPv6 address (%s)" % addr)
raise CustomException("You cannot force IPv4 with a litteral IPv6 address (%s)" % addr)
elif forceIPv6 and self.family == 4:
raise Exception("You cannot force IPv6 with a litteral IPv4 address (%s)" % addr)
raise CustomException("You cannot force IPv6 with a litteral IPv4 address (%s)" % addr)
if forceIPv4 or self.family == 4:
self.family = socket.AF_INET
self.repraddress = addr
......@@ -655,6 +659,8 @@ except TimeoutError:
error("timeout")
except ConnectionRefusedError:
error("Connection to server refused")
except CustomException as e:
error(e)
if ifile is not None:
input = open(ifile)
if not check:
......@@ -665,7 +671,7 @@ if not check:
name, rtype = get_next_domain(input)
try:
(rcode, msg, size) = conn.do_test(name, rtype)
except OpenSSL.SSL.Error as e:
except (OpenSSL.SSL.Error, CustomException) as e:
ok = False
error(e)
break
......
......@@ -236,9 +236,9 @@ tests:
- 'dot.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'IPv4 *or* IPv6'
stdout: ''
retcode: 2
stderr: ''
partstout: 'IPv4 *or* IPv6'
- exe: './check_dot'
name: '[check_dot] Force IPv4 and IPv6 with an IPv4'
......@@ -255,9 +255,9 @@ tests:
- 'dot.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'IPv4 *or* IPv6'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'IPv4 *or* IPv6'
- exe: './check_dot'
name: '[check_dot] Use IPv4 address and force IPv6'
......@@ -273,9 +273,9 @@ tests:
- 'dot.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'litteral IPv4'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'litteral IPv4'
- exe: './check_dot'
name: '[check_dot] Use IPv6 address and force IPv4'
......@@ -291,9 +291,9 @@ tests:
- 'dot.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'litteral IPv6'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'litteral IPv6'
################################################################################
......@@ -380,9 +380,9 @@ tests:
- 'doh.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'IPv4 *or* IPv6'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'IPv4 *or* IPv6'
- exe: './check_doh'
name: '[check_doh] Force IPv4 and IPv6 with an IPv4'
......@@ -399,9 +399,9 @@ tests:
- 'doh.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'IPv4 *or* IPv6'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'IPv4 *or* IPv6'
- exe: './check_doh'
name: '[check_doh] Use IPv4 address and force IPv6'
......@@ -417,9 +417,9 @@ tests:
- 'doh.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'litteral IPv4'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'litteral IPv4'
- exe: './check_doh'
name: '[check_doh] Use IPv6 address and force IPv4'
......@@ -435,9 +435,9 @@ tests:
- 'doh.bortzmeyer.fr'
- '-n'
- 'framagit.org'
retcode: 1
partstderr: 'litteral IPv6'
stdout: ''
retcode: 2
stderr: ''
partstdout: 'litteral IPv6'
################################################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment