diff options
author | 2016-04-09 16:17:53 +0100 | |
---|---|---|
committer | 2016-04-09 16:17:53 +0100 | |
commit | ad221f4b2afa0cf89810cd9c3b4e953913d602fc (patch) | |
tree | 23bf7561336d29096eb24d821265235f84ac4222 /middleware/testing/helpers.go | |
parent | db3d689a8ac2bec199e5643394ffa779341acde0 (diff) | |
download | coredns-ad221f4b2afa0cf89810cd9c3b4e953913d602fc.tar.gz coredns-ad221f4b2afa0cf89810cd9c3b4e953913d602fc.tar.zst coredns-ad221f4b2afa0cf89810cd9c3b4e953913d602fc.zip |
correct EDNS responses (#96)
Tests updated as well and all the middleware. And Prometheus renamed to
metrics (directive is still prometheus).
Diffstat (limited to 'middleware/testing/helpers.go')
-rw-r--r-- | middleware/testing/helpers.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/middleware/testing/helpers.go b/middleware/testing/helpers.go index e2b098cc7..49264ea1c 100644 --- a/middleware/testing/helpers.go +++ b/middleware/testing/helpers.go @@ -57,6 +57,18 @@ func MX(rr string) *dns.MX { r, _ := dns.NewRR(rr); return r.(*dns.MX) } func RRSIG(rr string) *dns.RRSIG { r, _ := dns.NewRR(rr); return r.(*dns.RRSIG) } func NSEC(rr string) *dns.NSEC { r, _ := dns.NewRR(rr); return r.(*dns.NSEC) } +func OPT(bufsize int, do bool) *dns.OPT { + o := new(dns.OPT) + o.Hdr.Name = "." + o.Hdr.Rrtype = dns.TypeOPT + o.SetVersion(0) + o.SetUDPSize(uint16(bufsize)) + if do { + o.SetDo() + } + return o +} + func Header(t *testing.T, tc Case, resp *dns.Msg) bool { if resp.Rcode != tc.Rcode { t.Errorf("rcode is %q, expected %q", dns.RcodeToString[resp.Rcode], dns.RcodeToString[tc.Rcode]) @@ -192,6 +204,16 @@ func Section(t *testing.T, tc Case, sect Sect, rr []dns.RR) bool { t.Errorf("NS nameserver should be %q, but is %q", x.Ns, tt.Ns) return false } + case *dns.OPT: + tt := section[i].(*dns.OPT) + if x.Do() != tt.Do() { + t.Errorf("OPT DO should be %q, but is %q", x.Do(), tt.Do()) + return false + } + if x.UDPSize() != tt.UDPSize() { + t.Errorf("OPT UDPSize should be %q, but is %q", x.UDPSize(), tt.UDPSize()) + return false + } } } return true |