mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
Issue 388 (#389)
* add extra test * middleware/auto: fix crash when calling empty handler Don't call the next middleware, we should be auth. for this zone getitng into this path we should respond with ServFail. Fixes #388
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user