aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-02-01 16:54:06 -0500
committerGravatar GitHub <noreply@github.com> 2022-02-01 16:54:06 -0500
commit911891f48513eef99ba0c80fae0c1e89f70649fe (patch)
tree36fb432a2f1de821ead00ac288097908118ed5c0 /test
parent49ee97994ee7677b521885eed965dac49728c77e (diff)
downloadcoredns-911891f48513eef99ba0c80fae0c1e89f70649fe.tar.gz
coredns-911891f48513eef99ba0c80fae0c1e89f70649fe.tar.zst
coredns-911891f48513eef99ba0c80fae0c1e89f70649fe.zip
plugin/rewrite: Write failures with ResponseReverter (#5150)
* write failures with ResponseReverter instead of letting server write them Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix comment Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'test')
-rw-r--r--test/rewrite_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/rewrite_test.go b/test/rewrite_test.go
index 310e43efa..d9ef09b15 100644
--- a/test/rewrite_test.go
+++ b/test/rewrite_test.go
@@ -7,6 +7,34 @@ import (
"github.com/miekg/dns"
)
+func TestRewriteFailure(t *testing.T) {
+ t.Parallel()
+ i, udp, _, err := CoreDNSServerAndPorts(`.:0 {
+ rewrite name regex (.*)\.test\.$ {1}. answer auto
+ # no next plugin to induce SERVFAIL
+ }`)
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+
+ defer i.Stop()
+
+ m := new(dns.Msg)
+ m.SetQuestion("example.test.", dns.TypeMX)
+
+ r, err := dns.Exchange(m, udp)
+ if err != nil {
+ t.Fatalf("Expected to receive reply, but didn't: %s", err)
+ }
+
+ if len(r.Question) == 0 {
+ t.Error("Invalid empty question section")
+ }
+ if r.Question[0].Name != "example.test." {
+ t.Errorf("Question section mismatch. expected \"example.test.\" got %q", r.Question[0].Name)
+ }
+}
+
func TestRewrite(t *testing.T) {
t.Parallel()
corefile := `.:0 {