Commit 931a8f35 authored by Alexandre's avatar Alexandre
Browse files

Define requests in function and use variable-length argument

parent d8dfc1a3
......@@ -181,6 +181,24 @@ class CustomException(Exception):
def create_request(dot=False, **req_args):
if dot:
request = RequestDoT(**req_args)
request = RequestDoH(**req_args)
return request
def create_requests_list(**req_args):
requests = []
if dot:
requests.append(('Test 1', create_request(dot=True, **req_args)))
requests.append(('Test 2', create_request(dot=True, **req_args)))
requests.append(('Test GET', create_request(**req_args), DOH_GET))
requests.append(('Test POST', create_request(**req_args), DOH_POST))
requests.append(('Test HEAD', create_request(**req_args), DOH_HEAD))
return requests
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)
......@@ -686,17 +704,8 @@ if not check:
if delay is not None:
if dot:
requests = [
('Test 1', RequestDoT(name, rtype, use_edns=edns, want_dnssec=dnssec)),
('Test 2', RequestDoT(name, rtype, use_edns=edns, want_dnssec=dnssec))
requests = [
('Test GET', RequestDoH(name, rtype, use_edns=edns, want_dnssec=dnssec), DOH_GET),
('Test POST', RequestDoH(name, rtype, use_edns=edns, want_dnssec=dnssec), DOH_POST),
('Test HEAD', RequestDoH(name, rtype, use_edns=edns, want_dnssec=dnssec), DOH_HEAD)
req_args = { 'qname': name, 'qtype': rtype, 'use_edns': edns, 'want_dnssec': dnssec }
requests = create_requests_list(**req_args)
for request_pack in requests:
if dot:
test_name, request = request_pack
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