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

Merge branch 'tests_ede' into 'master'

tests: dnspython now supports EDE

See merge request !1458
parents d350ef1b 46d2fb8c
No related branches found
No related tags found
1 merge request!1458tests: dnspython now supports EDE
Pipeline #100044 failed
dnspython>=1.16.0
dnspython>=2.2.0
psutil
......@@ -8,38 +8,15 @@ import os
import struct
import dns.edns
KNOT_EDNS_OPTION_EDE = 15
# this will work with future dnspython...
#class EdeOption(dns.edns.Option):
# def __init__(self, rcode):
# super().__init__(KNOT_EDNS_OPTION_EDE)
# self.rcode = rcode
# def to_text():
# return "EDE d" % rcode
# def to_wire(self, file=None):
# value = struct.pack('!H', self.rcode)
# if file:
# file.write(value)
# else:
# return value
# @classmethod
# def from_wire_parser(cls, otype, parser):
# rcode = parser.get_uint16()
# print("parsed " + rcode)
# return cls(rcode)
#dns.edns.register_type(EdeOption, KNOT_EDNS_OPTION_EDE)
def get_ede_rcode(option):
assert isinstance(option, dns.edns.GenericOption)
assert len(option.data) == 2
return struct.unpack('!H', option.data)[0]
assert isinstance(option, dns.edns.EDEOption)
return option.code
def get_ede(server, expect_ede, msg, qname, qtype="SOA"):
resp = server.dig(qname, qtype, edns=0)
ede = None
for o in resp.resp.options:
if o.otype == KNOT_EDNS_OPTION_EDE:
if o.otype == dns.edns.OptionType.EDE:
if ede is not None:
set_err(msg + ": multiple EDE")
ede = o
......@@ -54,32 +31,6 @@ def get_ede(server, expect_ede, msg, qname, qtype="SOA"):
if ede_rcode != expect_ede:
set_err(msg + ": wrong EDE %d != %d" % (ede_rcode, expect_ede))
KNOT_EDNS_EDE_OTHER = 0
KNOT_EDNS_EDE_DNSKEY_ALG = 1
KNOT_EDNS_EDE_DS_DIGEST = 2
KNOT_EDNS_EDE_STALE = 3
KNOT_EDNS_EDE_FORGED = 4
KNOT_EDNS_EDE_INDETERMINATE = 5
KNOT_EDNS_EDE_BOGUS = 6
KNOT_EDNS_EDE_SIG_EXPIRED = 7
KNOT_EDNS_EDE_SIG_NOTYET = 8
KNOT_EDNS_EDE_DNSKEY_MISS = 9
KNOT_EDNS_EDE_RRSIG_MISS = 10
KNOT_EDNS_EDE_DNSKEY_BIT = 11
KNOT_EDNS_EDE_NSEC_MISS = 12
KNOT_EDNS_EDE_CACHED_ERR = 13
KNOT_EDNS_EDE_NOT_READY = 14
KNOT_EDNS_EDE_BLOCKED = 15
KNOT_EDNS_EDE_CENSORED = 16
KNOT_EDNS_EDE_FILTERED = 17
KNOT_EDNS_EDE_PROHIBITED = 18
KNOT_EDNS_EDE_STALE_NXD = 19
KNOT_EDNS_EDE_NOTAUTH = 20
KNOT_EDNS_EDE_NOTSUP = 21
KNOT_EDNS_EDE_NREACH_AUTH = 22
KNOT_EDNS_EDE_NETWORK = 23
KNOT_EDNS_EDE_INV_DATA = 24
t = Test()
zones = t.zone_rnd(2)
......@@ -93,7 +44,7 @@ os.remove(master.zones[zones[1].name].zfile.path)
t.start()
master.zone_wait(zones[0])
get_ede(master, KNOT_EDNS_EDE_INV_DATA, "Not loaded", zones[1].name)
get_ede(master, KNOT_EDNS_EDE_NOTAUTH, "Out of zone", "out.of.zone.")
get_ede(master, dns.edns.EDECode.INVALID_DATA, "Not loaded", zones[1].name)
get_ede(master, dns.edns.EDECode.NOT_AUTHORITATIVE, "Out of zone", "out.of.zone.")
t.stop()
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