diff options
44 files changed, 223 insertions, 131 deletions
diff --git a/plugin/autopath/autopath_test.go b/plugin/autopath/autopath_test.go index a00bbf0a6..1d345c123 100644 --- a/plugin/autopath/autopath_test.go +++ b/plugin/autopath/autopath_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -49,7 +49,7 @@ func TestAutoPath(t *testing.T) { for _, tc := range autopathTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := ap.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) @@ -94,7 +94,7 @@ func TestAutoPathNoAnswer(t *testing.T) { for _, tc := range autopathNoAnswerTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rcode, err := ap.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/cache/prefech_test.go b/plugin/cache/prefech_test.go index 0e9d84da2..77a8f45ea 100644 --- a/plugin/cache/prefech_test.go +++ b/plugin/cache/prefech_test.go @@ -7,7 +7,7 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -29,7 +29,7 @@ func TestPrefetch(t *testing.T) { req := new(dns.Msg) req.SetQuestion("lowttl.example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) c.ServeDNS(ctx, rec, req) p = true // prefetch should be true for the 2nd fetch diff --git a/plugin/chaos/chaos_test.go b/plugin/chaos/chaos_test.go index 332d90381..e92c32aca 100644 --- a/plugin/chaos/chaos_test.go +++ b/plugin/chaos/chaos_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -59,7 +59,7 @@ func TestChaos(t *testing.T) { req.Question[0].Qclass = dns.ClassCHAOS em.Next = tc.next - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := em.ServeDNS(ctx, rec, req) if err != tc.expectedErr { diff --git a/plugin/dnssec/handler_test.go b/plugin/dnssec/handler_test.go index 2202a9ffe..ba24a45d1 100644 --- a/plugin/dnssec/handler_test.go +++ b/plugin/dnssec/handler_test.go @@ -6,7 +6,7 @@ import ( "github.com/coredns/coredns/plugin/file" "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -95,7 +95,7 @@ func TestLookupZone(t *testing.T) { for _, tc := range dnsTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := dh.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) @@ -118,7 +118,7 @@ func TestLookupDNSKEY(t *testing.T) { for _, tc := range dnssecTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := dh.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/erratic/erratic_test.go b/plugin/erratic/erratic_test.go index 7a1a420da..6927c5248 100644 --- a/plugin/erratic/erratic_test.go +++ b/plugin/erratic/erratic_test.go @@ -3,7 +3,7 @@ package erratic import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -28,7 +28,7 @@ func TestErraticDrop(t *testing.T) { req := new(dns.Msg) req.SetQuestion("example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := e.ServeDNS(ctx, rec, req) if err != tc.expectedErr { @@ -62,7 +62,7 @@ func TestErraticTruncate(t *testing.T) { req := new(dns.Msg) req.SetQuestion("example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := e.ServeDNS(ctx, rec, req) if err != tc.expectedErr { diff --git a/plugin/errors/errors_test.go b/plugin/errors/errors_test.go index 039562a56..ce965ec6b 100644 --- a/plugin/errors/errors_test.go +++ b/plugin/errors/errors_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -48,7 +48,7 @@ func TestErrors(t *testing.T) { for i, tc := range tests { em.Next = tc.next buf.Reset() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := em.ServeDNS(ctx, rec, req) if err != tc.expectedErr { diff --git a/plugin/etcd/cname_test.go b/plugin/etcd/cname_test.go index 7f53ccd64..dc3213655 100644 --- a/plugin/etcd/cname_test.go +++ b/plugin/etcd/cname_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -25,7 +25,7 @@ func TestCnameLookup(t *testing.T) { for _, tc := range dnsTestCasesCname { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := etc.ServeDNS(ctxt, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/etcd/group_test.go b/plugin/etcd/group_test.go index 1af1bdc7f..049bbd922 100644 --- a/plugin/etcd/group_test.go +++ b/plugin/etcd/group_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -22,7 +22,7 @@ func TestGroupLookup(t *testing.T) { for _, tc := range dnsTestCasesGroup { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := etc.ServeDNS(ctxt, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/etcd/lookup_test.go b/plugin/etcd/lookup_test.go index 1cd771a57..e185d341d 100644 --- a/plugin/etcd/lookup_test.go +++ b/plugin/etcd/lookup_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/singleflight" "github.com/coredns/coredns/plugin/pkg/tls" "github.com/coredns/coredns/plugin/proxy" @@ -262,7 +262,7 @@ func TestLookup(t *testing.T) { for _, tc := range dnsTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) etc.ServeDNS(ctxt, rec, m) resp := rec.Msg diff --git a/plugin/etcd/multi_test.go b/plugin/etcd/multi_test.go index 40d405bdf..3ff423d7e 100644 --- a/plugin/etcd/multi_test.go +++ b/plugin/etcd/multi_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -25,7 +25,7 @@ func TestMultiLookup(t *testing.T) { for _, tc := range dnsTestCasesMulti { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := etc.ServeDNS(ctxt, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/etcd/other_test.go b/plugin/etcd/other_test.go index 6399c770e..7e6e8febb 100644 --- a/plugin/etcd/other_test.go +++ b/plugin/etcd/other_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -26,7 +26,7 @@ func TestOtherLookup(t *testing.T) { for _, tc := range dnsTestCasesOther { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := etc.ServeDNS(ctxt, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/etcd/stub_test.go b/plugin/etcd/stub_test.go index 63635d849..818457ac2 100644 --- a/plugin/etcd/stub_test.go +++ b/plugin/etcd/stub_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -51,7 +51,7 @@ func TestStubLookup(t *testing.T) { for _, tc := range dnsTestCasesStub { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := etc.ServeDNS(ctxt, rec, m) if err != nil && m.Question[0].Name == "example.org." { // This is OK, we expect this backend to *not* work. diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index 920f1a340..f91f4c676 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/coredns/coredns/plugin/kubernetes" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -68,7 +68,7 @@ func TestFederationKubernetes(t *testing.T) { for i, tc := range tests { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fed.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Test %d, expected no error, got %v\n", i, err) diff --git a/plugin/file/cname_test.go b/plugin/file/cname_test.go index 1178a7512..f3b3a7731 100644 --- a/plugin/file/cname_test.go +++ b/plugin/file/cname_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/proxy" "github.com/coredns/coredns/plugin/test" @@ -25,7 +25,7 @@ func TestLookupCNAMEChain(t *testing.T) { for _, tc := range cnameTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -82,7 +82,7 @@ func TestLookupCNAMEExternal(t *testing.T) { for _, tc := range exernalTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/file/delegation_test.go b/plugin/file/delegation_test.go index 1ad9804f4..cbf1d703a 100644 --- a/plugin/file/delegation_test.go +++ b/plugin/file/delegation_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -162,7 +162,7 @@ func testDelegation(t *testing.T, z, origin string, testcases []test.Case) { for _, tc := range testcases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %q\n", err) diff --git a/plugin/file/dname_test.go b/plugin/file/dname_test.go index 92e33dde7..ebb0780a0 100644 --- a/plugin/file/dname_test.go +++ b/plugin/file/dname_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -101,7 +101,7 @@ func TestLookupDNAME(t *testing.T) { for _, tc := range dnameTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -154,7 +154,7 @@ func TestLookupDNAMEDNSSEC(t *testing.T) { for _, tc := range dnameDnssecTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/file/dnssec_test.go b/plugin/file/dnssec_test.go index 17b122c7e..eb6374b03 100644 --- a/plugin/file/dnssec_test.go +++ b/plugin/file/dnssec_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -138,7 +138,7 @@ func TestLookupDNSSEC(t *testing.T) { for _, tc := range dnssecTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -158,7 +158,7 @@ func BenchmarkFileLookupDNSSEC(b *testing.B) { fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} ctx := context.TODO() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) tc := test.Case{ Qname: "b.miek.nl.", Qtype: dns.TypeA, Do: true, diff --git a/plugin/file/ds_test.go b/plugin/file/ds_test.go index e1087a81d..537d47def 100644 --- a/plugin/file/ds_test.go +++ b/plugin/file/ds_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -62,7 +62,7 @@ func TestLookupDS(t *testing.T) { for _, tc := range dsTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/file/ent_test.go b/plugin/file/ent_test.go index 6f4f1db6c..124b4688b 100644 --- a/plugin/file/ent_test.go +++ b/plugin/file/ent_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -42,7 +42,7 @@ func TestLookupEnt(t *testing.T) { for _, tc := range entTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) diff --git a/plugin/file/glue_test.go b/plugin/file/glue_test.go index 3880953c2..bf523a90b 100644 --- a/plugin/file/glue_test.go +++ b/plugin/file/glue_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -44,7 +44,7 @@ func TestLookupGlue(t *testing.T) { for _, tc := range atoomTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/file/lookup_test.go b/plugin/file/lookup_test.go index 8fd93fd8e..dd922c1b6 100644 --- a/plugin/file/lookup_test.go +++ b/plugin/file/lookup_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -114,7 +114,7 @@ func TestLookup(t *testing.T) { for _, tc := range dnsTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("expected no error, got %v\n", err) @@ -131,7 +131,7 @@ func TestLookupNil(t *testing.T) { ctx := context.TODO() m := dnsTestCases[0].Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) fm.ServeDNS(ctx, rec, m) } @@ -143,7 +143,7 @@ func BenchmarkFileLookup(b *testing.B) { fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} ctx := context.TODO() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) tc := test.Case{ Qname: "www.miek.nl.", Qtype: dns.TypeA, diff --git a/plugin/file/wildcard_test.go b/plugin/file/wildcard_test.go index 038d37a43..bc111e94b 100644 --- a/plugin/file/wildcard_test.go +++ b/plugin/file/wildcard_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -89,7 +89,7 @@ func TestLookupWildcard(t *testing.T) { for _, tc := range wildcardTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -150,7 +150,7 @@ func TestLookupDoubleWildcard(t *testing.T) { for _, tc := range wildcardDoubleTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -205,7 +205,7 @@ func TestLookupApexWildcard(t *testing.T) { for _, tc := range apexWildcardTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) @@ -248,7 +248,7 @@ func TestLookupMultiWildcard(t *testing.T) { for _, tc := range multiWildcardTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := fm.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/hosts/hosts_test.go b/plugin/hosts/hosts_test.go index 68b91b8c2..3c9405562 100644 --- a/plugin/hosts/hosts_test.go +++ b/plugin/hosts/hosts_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -21,7 +21,7 @@ func TestLookupA(t *testing.T) { for _, tc := range hostsTestCases { m := tc.Msg() - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := h.ServeDNS(ctx, rec, m) if err != nil { t.Errorf("Expected no error, got %v\n", err) diff --git a/plugin/kubernetes/handler_pod_disabled_test.go b/plugin/kubernetes/handler_pod_disabled_test.go index 4c6e15710..19dd84bdc 100644 --- a/plugin/kubernetes/handler_pod_disabled_test.go +++ b/plugin/kubernetes/handler_pod_disabled_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -40,7 +40,7 @@ func TestServeDNSModeDisabled(t *testing.T) { for i, tc := range podModeDisabledCases { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/kubernetes/handler_pod_insecure_test.go b/plugin/kubernetes/handler_pod_insecure_test.go index b2df8a504..f99526e10 100644 --- a/plugin/kubernetes/handler_pod_insecure_test.go +++ b/plugin/kubernetes/handler_pod_insecure_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -38,7 +38,7 @@ func TestServeDNSModeInsecure(t *testing.T) { for i, tc := range podModeInsecureCases { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/kubernetes/handler_pod_verified_test.go b/plugin/kubernetes/handler_pod_verified_test.go index ea585cc6a..35aa92c05 100644 --- a/plugin/kubernetes/handler_pod_verified_test.go +++ b/plugin/kubernetes/handler_pod_verified_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -38,7 +38,7 @@ func TestServeDNSModeVerified(t *testing.T) { for i, tc := range podModeVerifiedCases { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/kubernetes/handler_test.go b/plugin/kubernetes/handler_test.go index 5413f5b4c..1dd7ea621 100644 --- a/plugin/kubernetes/handler_test.go +++ b/plugin/kubernetes/handler_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -165,7 +165,7 @@ func TestServeDNS(t *testing.T) { for i, tc := range dnsTestCases { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/kubernetes/kubernetes_apex_test.go b/plugin/kubernetes/kubernetes_apex_test.go index 41b70b883..ce9cf59d4 100644 --- a/plugin/kubernetes/kubernetes_apex_test.go +++ b/plugin/kubernetes/kubernetes_apex_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -47,7 +47,7 @@ func TestServeDNSApex(t *testing.T) { for i, tc := range kubeApexCases { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/kubernetes/reverse_test.go b/plugin/kubernetes/reverse_test.go index aa9d09585..d5b673be7 100644 --- a/plugin/kubernetes/reverse_test.go +++ b/plugin/kubernetes/reverse_test.go @@ -3,7 +3,7 @@ package kubernetes import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -108,7 +108,7 @@ func TestReverse(t *testing.T) { for i, tc := range tests { r := tc.Msg() - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := k.ServeDNS(ctx, w, r) if err != tc.Error { diff --git a/plugin/loadbalance/loadbalance_test.go b/plugin/loadbalance/loadbalance_test.go index bde92b543..0d1a0b189 100644 --- a/plugin/loadbalance/loadbalance_test.go +++ b/plugin/loadbalance/loadbalance_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -79,7 +79,7 @@ func TestLoadBalance(t *testing.T) { }, } - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) for i, test := range tests { req := new(dns.Msg) diff --git a/plugin/log/log.go b/plugin/log/log.go index 52af79d35..762e31ee3 100644 --- a/plugin/log/log.go +++ b/plugin/log/log.go @@ -7,7 +7,7 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/metrics/vars" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/rcode" "github.com/coredns/coredns/plugin/pkg/replacer" "github.com/coredns/coredns/plugin/pkg/response" @@ -32,7 +32,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) continue } - rrw := dnsrecorder.New(w) + rrw := dnstest.NewRecorder(w) rc, err := plugin.NextOrFailure(l.Name(), l.Next, ctx, rrw, r) if rc > 0 { diff --git a/plugin/log/log_test.go b/plugin/log/log_test.go index ee1201a13..05271478c 100644 --- a/plugin/log/log_test.go +++ b/plugin/log/log_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/response" "github.com/coredns/coredns/plugin/test" @@ -31,7 +31,7 @@ func TestLoggedStatus(t *testing.T) { r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rcode, _ := logger.ServeDNS(ctx, rec, r) if rcode != 0 { @@ -62,7 +62,7 @@ func TestLoggedClassDenial(t *testing.T) { r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) logger.ServeDNS(ctx, rec, r) @@ -90,7 +90,7 @@ func TestLoggedClassError(t *testing.T) { r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeA) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) logger.ServeDNS(ctx, rec, r) diff --git a/plugin/metrics/handler.go b/plugin/metrics/handler.go index bc9a6ec47..88bc1b634 100644 --- a/plugin/metrics/handler.go +++ b/plugin/metrics/handler.go @@ -3,7 +3,7 @@ package metrics import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/metrics/vars" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/rcode" "github.com/coredns/coredns/request" @@ -22,7 +22,7 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg } // Record response to get status code and size of the reply. - rw := dnsrecorder.New(w) + rw := dnstest.NewRecorder(w) status, err := plugin.NextOrFailure(m.Name(), m.Next, ctx, rw, r) vars.Report(state, zone, rcode.ToString(rw.Rcode), rw.Len, rw.Start) diff --git a/plugin/metrics/metrics_test.go b/plugin/metrics/metrics_test.go index f5a17607c..54e7859e8 100644 --- a/plugin/metrics/metrics_test.go +++ b/plugin/metrics/metrics_test.go @@ -5,7 +5,7 @@ import ( "github.com/coredns/coredns/plugin" mtest "github.com/coredns/coredns/plugin/metrics/test" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -65,7 +65,7 @@ func TestMetrics(t *testing.T) { req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) met.Next = tc.next - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) _, err := met.ServeDNS(ctx, rec, req) if err != nil { t.Fatalf("Test %d: Expected no error, but got %s", i, err) diff --git a/plugin/pkg/dnsrecorder/recorder_test.go b/plugin/pkg/dnsrecorder/recorder_test.go deleted file mode 100644 index c9c2f6ce4..000000000 --- a/plugin/pkg/dnsrecorder/recorder_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package dnsrecorder - -/* -func TestNewResponseRecorder(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - if !(recordRequest.ResponseWriter == w) { - t.Fatalf("Expected Response writer in the Recording to be same as the one sent\n") - } - if recordRequest.status != http.StatusOK { - t.Fatalf("Expected recorded status to be http.StatusOK (%d) , but found %d\n ", http.StatusOK, recordRequest.status) - } -} - -func TestWrite(t *testing.T) { - w := httptest.NewRecorder() - responseTestString := "test" - recordRequest := NewResponseRecorder(w) - buf := []byte(responseTestString) - recordRequest.Write(buf) - if recordRequest.size != len(buf) { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", len(buf), recordRequest.size) - } - if w.Body.String() != responseTestString { - t.Fatalf("Expected Response Body to be %s , but found %s\n", responseTestString, w.Body.String()) - } -} -*/ diff --git a/plugin/pkg/dnsrecorder/recorder.go b/plugin/pkg/dnstest/recorder.go index 3ca5f00d0..1de68f8fc 100644 --- a/plugin/pkg/dnsrecorder/recorder.go +++ b/plugin/pkg/dnstest/recorder.go @@ -1,5 +1,5 @@ -// Package dnsrecorder allows you to record a DNS response when it is send to the client. -package dnsrecorder +// Package dnstest allows for easy testing of DNS client against a test server. +package dnstest import ( "time" @@ -24,7 +24,7 @@ type Recorder struct { // New makes and returns a new Recorder, // which captures the DNS rcode from the ResponseWriter // and also the length of the response message written through it. -func New(w dns.ResponseWriter) *Recorder { +func NewRecorder(w dns.ResponseWriter) *Recorder { return &Recorder{ ResponseWriter: w, Rcode: 0, @@ -52,7 +52,3 @@ func (r *Recorder) Write(buf []byte) (int, error) { } return n, err } - -// Hijack implements dns.Hijacker. It simply wraps the underlying -// ResponseWriter's Hijack method if there is one, or returns an error. -func (r *Recorder) Hijack() { r.ResponseWriter.Hijack(); return } diff --git a/plugin/pkg/dnstest/recorder_test.go b/plugin/pkg/dnstest/recorder_test.go new file mode 100644 index 000000000..96af7b01b --- /dev/null +++ b/plugin/pkg/dnstest/recorder_test.go @@ -0,0 +1,50 @@ +package dnstest + +import ( + "testing" + + "github.com/miekg/dns" +) + +type responseWriter struct{ dns.ResponseWriter } + +func (r *responseWriter) WriteMsg(m *dns.Msg) error { return nil } +func (r *responseWriter) Write(buf []byte) (int, error) { return len(buf), nil } + +func TestNewRecorder(t *testing.T) { + w := &responseWriter{} + record := NewRecorder(w) + if record.ResponseWriter != w { + t.Fatalf("Expected Response writer in the Recording to be same as the one sent\n") + } + if record.Rcode != dns.RcodeSuccess { + t.Fatalf("Expected recorded status to be dns.RcodeSuccess (%d) , but found %d\n ", dns.RcodeSuccess, record.Rcode) + } +} + +func TestWriteMsg(t *testing.T) { + w := &responseWriter{} + record := NewRecorder(w) + responseTestName := "testmsg.example.org." + responseTestMsg := new(dns.Msg) + responseTestMsg.SetQuestion(responseTestName, dns.TypeA) + + record.WriteMsg(responseTestMsg) + if record.Len != responseTestMsg.Len() { + t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len(), record.Len) + } + if x := record.Msg.Question[0].Name; x != responseTestName { + t.Fatalf("Expected Msg Qname to be %s , but found %s\n", responseTestName, x) + } +} + +func TestWrite(t *testing.T) { + w := &responseWriter{} + record := NewRecorder(w) + responseTest := []byte("testmsg.example.org.") + + record.Write(responseTest) + if record.Len != len(responseTest) { + t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", len(responseTest), record.Len) + } +} diff --git a/plugin/pkg/dnstest/server.go b/plugin/pkg/dnstest/server.go new file mode 100644 index 000000000..72437cf8b --- /dev/null +++ b/plugin/pkg/dnstest/server.go @@ -0,0 +1,46 @@ +package dnstest + +import ( + "net" + + "github.com/miekg/dns" +) + +// A Server is an DNS server listening on a system-chosen port on the local +// loopback interface, for use in end-to-end DNS tests. +type Server struct { + Addr string // Address where the server listening. + + s1 *dns.Server // udp + s2 *dns.Server // tcp +} + +// NewServer starts and returns a new Server. The caller should call Close when +// finished, to shut it down. +func NewServer(f dns.HandlerFunc) *Server { + dns.HandleFunc(".", f) + + ch1 := make(chan bool) + ch2 := make(chan bool) + + p, _ := net.ListenPacket("udp", ":0") + l, _ := net.Listen("tcp", p.LocalAddr().String()) + + s1 := &dns.Server{PacketConn: p} + s2 := &dns.Server{Listener: l} + s1.NotifyStartedFunc = func() { close(ch1) } + s2.NotifyStartedFunc = func() { close(ch2) } + go s1.ActivateAndServe() + go s2.ActivateAndServe() + + <-ch1 + <-ch2 + + return &Server{s1: s1, s2: s2, Addr: p.LocalAddr().String()} +} + +// Close shuts down the server. +func (s *Server) Close() { + s.s1.Shutdown() + s.s2.Shutdown() +} diff --git a/plugin/pkg/dnstest/server_test.go b/plugin/pkg/dnstest/server_test.go new file mode 100644 index 000000000..3f23c340b --- /dev/null +++ b/plugin/pkg/dnstest/server_test.go @@ -0,0 +1,28 @@ +package dnstest + +import ( + "testing" + + "github.com/miekg/dns" +) + +func TestNewServer(t *testing.T) { + s := NewServer(func(w dns.ResponseWriter, r *dns.Msg) { + ret := new(dns.Msg) + ret.SetReply(r) + w.WriteMsg(ret) + }) + defer s.Close() + + c := new(dns.Client) + c.Net = "tcp" + m := new(dns.Msg) + m.SetQuestion("example.org.", dns.TypeSOA) + ret, _, err := c.Exchange(m, s.Addr) + if err != nil { + t.Fatalf("Could not send message to dnstest.Server: %s", err) + } + if ret.Id != m.Id { + t.Fatalf("Msg ID's should match, expected %d, got %d", m.Id, ret.Id) + } +} diff --git a/plugin/pkg/replacer/replacer.go b/plugin/pkg/replacer/replacer.go index fc98e5d29..c10022f79 100644 --- a/plugin/pkg/replacer/replacer.go +++ b/plugin/pkg/replacer/replacer.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -31,7 +31,7 @@ type replacer struct { // values into the replacer. rr may be nil if it is not // available. emptyValue should be the string that is used // in place of empty string (can still be empty string). -func New(r *dns.Msg, rr *dnsrecorder.Recorder, emptyValue string) Replacer { +func New(r *dns.Msg, rr *dnstest.Recorder, emptyValue string) Replacer { req := request.Request{W: rr, Req: r} rep := replacer{ replacements: map[string]string{ diff --git a/plugin/pkg/replacer/replacer_test.go b/plugin/pkg/replacer/replacer_test.go index 95c3bbd52..65bb8280f 100644 --- a/plugin/pkg/replacer/replacer_test.go +++ b/plugin/pkg/replacer/replacer_test.go @@ -3,14 +3,14 @@ package replacer import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" ) func TestNewReplacer(t *testing.T) { - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeHINFO) @@ -37,7 +37,7 @@ func TestNewReplacer(t *testing.T) { } func TestSet(t *testing.T) { - w := dnsrecorder.New(&test.ResponseWriter{}) + w := dnstest.NewRecorder(&test.ResponseWriter{}) r := new(dns.Msg) r.SetQuestion("example.org.", dns.TypeHINFO) diff --git a/plugin/reverse/reverse_test.go b/plugin/reverse/reverse_test.go index c7a7fea6c..6789c7cc8 100644 --- a/plugin/reverse/reverse_test.go +++ b/plugin/reverse/reverse_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -52,7 +52,7 @@ func TestReverse(t *testing.T) { tr.qtype = dns.TypeA req.SetQuestion(dns.Fqdn(tr.qname), tr.qtype) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := em.ServeDNS(ctx, rec, req) if err != tr.expectedErr { diff --git a/plugin/rewrite/rewrite_test.go b/plugin/rewrite/rewrite_test.go index 9ce87e517..33439cefd 100644 --- a/plugin/rewrite/rewrite_test.go +++ b/plugin/rewrite/rewrite_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -180,7 +180,7 @@ func TestRewrite(t *testing.T) { m.SetQuestion(tc.from, tc.fromT) m.Question[0].Qclass = tc.fromC - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rw.ServeDNS(ctx, rec, m) resp := rec.Msg @@ -252,7 +252,7 @@ func TestRewriteEDNS0Local(t *testing.T) { } rw.Rules = []Rule{r} - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rw.ServeDNS(ctx, rec, m) resp := rec.Msg @@ -307,7 +307,7 @@ func TestEdns0LocalMultiRule(t *testing.T) { } o.Option = append(o.Option, tc.fromOpts...) } - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rw.ServeDNS(ctx, rec, m) resp := rec.Msg @@ -443,7 +443,7 @@ func TestRewriteEDNS0LocalVariable(t *testing.T) { } rw.Rules = []Rule{r} - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) rw.ServeDNS(ctx, rec, m) resp := rec.Msg @@ -553,7 +553,7 @@ func TestRewriteEDNS0Subnet(t *testing.T) { continue } rw.Rules = []Rule{r} - rec := dnsrecorder.New(tc.writer) + rec := dnstest.NewRecorder(tc.writer) rw.ServeDNS(ctx, rec, m) resp := rec.Msg diff --git a/plugin/whoami/whoami_test.go b/plugin/whoami/whoami_test.go index c8e57f80c..0fee7d03f 100644 --- a/plugin/whoami/whoami_test.go +++ b/plugin/whoami/whoami_test.go @@ -3,7 +3,7 @@ package whoami import ( "testing" - "github.com/coredns/coredns/plugin/pkg/dnsrecorder" + "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" @@ -35,7 +35,7 @@ func TestWhoami(t *testing.T) { req := new(dns.Msg) req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - rec := dnsrecorder.New(&test.ResponseWriter{}) + rec := dnstest.NewRecorder(&test.ResponseWriter{}) code, err := wh.ServeDNS(ctx, rec, req) if err != tc.expectedErr { |