tests-extra: add simple transfer response check

This commit is contained in:
Daniel Salzman 2014-11-11 14:39:58 +01:00 committed by Lubos Slovak
parent 048e83a9e5
commit 5c9c501f2d
2 changed files with 22 additions and 0 deletions

View file

@ -17,6 +17,7 @@ t.start()
serial_init = knot.zone_wait(zone)
resp = knot.dig("example.com", "IXFR", serial=serial_init + 1)
resp.check_xfr()
compare(resp.msg_count(), 1, "Only one message")
compare(resp.count("SOA"), 1, "Only one RR in Answer section")

View file

@ -139,6 +139,27 @@ class Response(object):
self.check_record(section="answer", rtype=self.rtype, ttl=ttl,
rdata=rdata, nordata=nordata)
def check_xfr(self, rcode="NOERROR"):
'''Checks XFR message'''
self.resp, iter_copy = itertools.tee(self.resp)
# Get the first message.
for msg in iter_copy:
question = msg.question[0]
compare(question.rdclass, self.rclass, "QCLASS")
compare(question.rdtype, self.rtype, "QTYPE")
# Check rcode.
if type(rcode) is not str:
rc = dns.rcode.to_text(rcode)
else:
rc = rcode
compare(dns.rcode.to_text(msg.rcode()), rc, "RCODE")
# Check the first message only.
break
def check_edns(self, nsid=None, buff_size=None):
compare(self.resp.edns, 0, "EDNS VERSION")