mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 03:45:11 -05:00
plugin/template: fix CNAME upstream handling (#1886)
This commit is contained in:
@@ -92,6 +92,14 @@ func TestHandler(t *testing.T) {
|
||||
fall: fall.Root,
|
||||
zones: []string{"."},
|
||||
}
|
||||
cnameTemplate := template{
|
||||
regex: []*regexp.Regexp{regexp.MustCompile("example[.]net[.]")},
|
||||
answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("example.net 60 IN CNAME target.example.com"))},
|
||||
qclass: dns.ClassANY,
|
||||
qtype: dns.TypeANY,
|
||||
fall: fall.Root,
|
||||
zones: []string{"."},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
tmpl template
|
||||
@@ -254,6 +262,20 @@ func TestHandler(t *testing.T) {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CNAMEWithoutUpstream",
|
||||
tmpl: cnameTemplate,
|
||||
qclass: dns.ClassINET,
|
||||
qtype: dns.TypeA,
|
||||
qname: "example.net.",
|
||||
expectedCode: dns.RcodeSuccess,
|
||||
verifyResponse: func(r *dns.Msg) error {
|
||||
if len(r.Answer) != 1 {
|
||||
return fmt.Errorf("expected 1 answer, got %v", len(r.Answer))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
Reference in New Issue
Block a user