aboutsummaryrefslogtreecommitdiff
path: root/test/auto_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/auto_test.go')
-rw-r--r--test/auto_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/auto_test.go b/test/auto_test.go
index 525e58df3..d9ca5f9da 100644
--- a/test/auto_test.go
+++ b/test/auto_test.go
@@ -79,6 +79,44 @@ func TestAuto(t *testing.T) {
}
}
+func TestAutoNonExistentZone(t *testing.T) {
+ tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ if err != nil {
+ t.Fatal(err)
+ }
+ log.SetOutput(ioutil.Discard)
+
+ corefile := `.:0 {
+ auto {
+ directory ` + tmpdir + ` (.*) {1} 1
+ }
+ errors stdout
+ }
+`
+
+ i, err := CoreDNSServer(corefile)
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+
+ udp, _ := CoreDNSServerPorts(i, 0)
+ if udp == "" {
+ t.Fatalf("Could not get UDP listening port")
+ }
+ defer i.Stop()
+
+ p := proxy.New([]string{udp})
+ state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
+
+ resp, err := p.Lookup(state, "example.org.", dns.TypeA)
+ if err != nil {
+ t.Fatal("Expected to receive reply, but didn't")
+ }
+ if resp.Rcode != dns.RcodeServerFailure {
+ t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode)
+ }
+}
+
const zoneContent = `; testzone
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082534 7200 3600 1209600 3600
NS a.iana-servers.net.