aboutsummaryrefslogtreecommitdiff
path: root/plugin/proxy/proxy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/proxy/proxy_test.go')
-rw-r--r--plugin/proxy/proxy_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugin/proxy/proxy_test.go b/plugin/proxy/proxy_test.go
index 0d29c2329..3057715a4 100644
--- a/plugin/proxy/proxy_test.go
+++ b/plugin/proxy/proxy_test.go
@@ -9,7 +9,12 @@ import (
"testing"
"time"
+ "github.com/coredns/coredns/plugin/pkg/dnstest"
+ "github.com/coredns/coredns/plugin/test"
+ "github.com/coredns/coredns/request"
+
"github.com/mholt/caddy/caddyfile"
+ "github.com/miekg/dns"
)
func TestStop(t *testing.T) {
@@ -70,3 +75,25 @@ func TestStop(t *testing.T) {
})
}
}
+
+func TestProxyRefused(t *testing.T) {
+ s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
+ ret := new(dns.Msg)
+ ret.SetReply(r)
+ ret.Rcode = dns.RcodeRefused
+ w.WriteMsg(ret)
+ })
+ defer s.Close()
+
+ p := NewLookup([]string{s.Addr})
+
+ state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
+ state.Req.SetQuestion("example.org.", dns.TypeA)
+ resp, err := p.Forward(state)
+ if err != nil {
+ t.Fatal("Expected to receive reply, but didn't")
+ }
+ if resp.Rcode != dns.RcodeRefused {
+ t.Errorf("Expected rcode to be %d, got %d", dns.RcodeRefused, resp.Rcode)
+ }
+}