aboutsummaryrefslogtreecommitdiff
path: root/plugin/erratic/erratic_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-07-20 10:25:54 +0100
committerGravatar GitHub <noreply@github.com> 2018-07-20 10:25:54 +0100
commitd998aa6c25ffe83e2d2abf9ba52c5ada57da7e30 (patch)
tree4e83faf380c6a79b6295db3a230bdbac3a0ba65b /plugin/erratic/erratic_test.go
parentf3134da45eb2808431a29fa55c58e3271bbba637 (diff)
downloadcoredns-d998aa6c25ffe83e2d2abf9ba52c5ada57da7e30.tar.gz
coredns-d998aa6c25ffe83e2d2abf9ba52c5ada57da7e30.tar.zst
coredns-d998aa6c25ffe83e2d2abf9ba52c5ada57da7e30.zip
plugin/erratic: add axfr support (#1977)
* plugin/erratic: add axfr support Add support for axfr. This to fix and test long standing axfr issues that are hard to test if we don't support it directly in coredns. The most intriguing feature is withholding the last SOA from a response so the client needs to wait; drop (no reply) and delay is also supported. All TTLs are set to zero. Add simple tests that checks if first record is a SOA. Signed-off-by: Miek Gieben <miek@miek.nl> * more test coverage Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/erratic/erratic_test.go')
-rw-r--r--plugin/erratic/erratic_test.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/plugin/erratic/erratic_test.go b/plugin/erratic/erratic_test.go
index 8a3b4e011..406fd8774 100644
--- a/plugin/erratic/erratic_test.go
+++ b/plugin/erratic/erratic_test.go
@@ -14,19 +14,22 @@ func TestErraticDrop(t *testing.T) {
e := &Erratic{drop: 2} // 50% drops
tests := []struct {
+ rrtype uint16
expectedCode int
expectedErr error
drop bool
}{
- {expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: true},
- {expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: false},
+ {rrtype: dns.TypeA, expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: true},
+ {rrtype: dns.TypeA, expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: false},
+ {rrtype: dns.TypeAAAA, expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: true},
+ {rrtype: dns.TypeHINFO, expectedCode: dns.RcodeServerFailure, expectedErr: nil, drop: false},
}
ctx := context.TODO()
for i, tc := range tests {
req := new(dns.Msg)
- req.SetQuestion("example.org.", dns.TypeA)
+ req.SetQuestion("example.org.", tc.rrtype)
rec := dnstest.NewRecorder(&test.ResponseWriter{})
code, err := e.ServeDNS(ctx, rec, req)
@@ -77,3 +80,21 @@ func TestErraticTruncate(t *testing.T) {
}
}
}
+
+func TestAxfr(t *testing.T) {
+ e := &Erratic{truncate: 0} // nothing, just check if we can get an axfr
+
+ ctx := context.TODO()
+
+ req := new(dns.Msg)
+ req.SetQuestion("example.org.", dns.TypeAXFR)
+
+ rec := dnstest.NewRecorder(&test.ResponseWriter{})
+ _, err := e.ServeDNS(ctx, rec, req)
+ if err != nil {
+ t.Errorf("Failed to set up AXFR: %s", err)
+ }
+ if x := rec.Msg.Answer[0].Header().Rrtype; x != dns.TypeSOA {
+ t.Errorf("Expected for record to be %d, got %d", dns.TypeSOA, x)
+ }
+}