Skip to content
Snippets Groups Projects
Commit 26cf97e4 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

tests-extra: add test for EDNS version

parent 62b36ecf
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
'''Test for EDNS version'''
from dnstest.test import Test
t = Test()
server = t.server("knot")
zone = t.zone("example.com.")
t.link(zone, server)
t.start()
# Supported EDNS version 0.
resp = server.dig("example.com", "SOA", edns=0)
resp.check(rcode="NOERROR")
# Unsupported EDNS version 1.
resp = server.dig("example.com", "SOA", edns=1)
resp.check(rcode="BADVERS")
t.end()
......@@ -393,7 +393,7 @@ class Server(object):
f.close
def dig(self, rname, rtype, rclass="IN", udp=None, serial=None,
timeout=None, tries=3, flags="", bufsize=None,
timeout=None, tries=3, flags="", bufsize=None, edns=None,
nsid=False, dnssec=False, log_no_sep=False):
key_params = self.tsig_test.key_params if self.tsig_test else dict()
......@@ -458,7 +458,7 @@ class Server(object):
dig_flags += " +cd"
# Set EDNS.
if nsid or bufsize:
if edns != None or bufsize or nsid:
class NsidFix(object):
'''Current pythondns doesn't implement NSID option.'''
def __init__(self):
......@@ -466,6 +466,12 @@ class Server(object):
def to_wire(self, file=None):
pass
if edns:
edns = int(edns)
else:
edns = 0
dig_flags += " +edns=%i" % edns
if bufsize:
payload = int(bufsize)
else:
......@@ -478,7 +484,7 @@ class Server(object):
else:
options = None
query.use_edns(edns=0, payload=payload, options=options)
query.use_edns(edns=edns, payload=payload, options=options)
# Set DO flag.
if dnssec:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment