aboutsummaryrefslogtreecommitdiff
path: root/plugin/rewrite/name_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/rewrite/name_test.go')
-rw-r--r--plugin/rewrite/name_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/plugin/rewrite/name_test.go b/plugin/rewrite/name_test.go
new file mode 100644
index 000000000..57fb1eaa9
--- /dev/null
+++ b/plugin/rewrite/name_test.go
@@ -0,0 +1,33 @@
+package rewrite
+
+import (
+ "context"
+ "strings"
+ "testing"
+
+ "github.com/coredns/coredns/plugin"
+ "github.com/coredns/coredns/plugin/pkg/dnstest"
+ "github.com/coredns/coredns/plugin/test"
+
+ "github.com/miekg/dns"
+)
+
+func TestRewriteIllegalName(t *testing.T) {
+ r, _ := newNameRule("stop", "example.org.", "example..org.")
+
+ rw := Rewrite{
+ Next: plugin.HandlerFunc(msgPrinter),
+ Rules: []Rule{r},
+ noRevert: true,
+ }
+
+ ctx := context.TODO()
+ m := new(dns.Msg)
+ m.SetQuestion("example.org.", dns.TypeA)
+
+ rec := dnstest.NewRecorder(&test.ResponseWriter{})
+ _, err := rw.ServeDNS(ctx, rec, m)
+ if !strings.Contains(err.Error(), "invalid name") {
+ t.Errorf("Expected invalid name, got %s", err.Error())
+ }
+}