added additional cname test cases
tests now check for cname records when `a` records are requested
This commit is contained in:
+41
-11
@@ -103,7 +103,7 @@ func RunTestLookupCheckCNAME(t *testing.T, tc test.Case, resp *dns.Msg) bool {
|
|||||||
if err := test.CNAMEOrder(resp); err != nil {
|
if err := test.CNAMEOrder(resp); err != nil {
|
||||||
t.Errorf("cname response out of order")
|
t.Errorf("cname response out of order")
|
||||||
}
|
}
|
||||||
if tc.Qtype == dns.TypeCNAME {
|
if tc.Qtype == dns.TypeCNAME || RunTestLookupContainsCNAME(resp) {
|
||||||
if err := test.Header(tc, resp); err != nil {
|
if err := test.Header(tc, resp); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -121,6 +121,16 @@ func RunTestLookupCheckCNAME(t *testing.T, tc test.Case, resp *dns.Msg) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RunTestLookupContainsCNAME(resp *dns.Msg) bool {
|
||||||
|
out := false
|
||||||
|
for _, rr := range resp.Answer {
|
||||||
|
if rr.Header().Rrtype == dns.TypeCNAME {
|
||||||
|
out = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
exampledotcomName string = "example.com."
|
exampledotcomName string = "example.com."
|
||||||
subdotexampledotcomName string = "sub.example.com."
|
subdotexampledotcomName string = "sub.example.com."
|
||||||
@@ -150,6 +160,12 @@ var (
|
|||||||
exampledotcomNS1Record6,
|
exampledotcomNS1Record6,
|
||||||
exampledotcomNS2Record6,
|
exampledotcomNS2Record6,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
webdotexampledotcomName string = "web.example.com."
|
||||||
|
webdotexampledotcomRecordA dns.RR = test.A("web.example.com. 3600 IN A 10.0.0.17")
|
||||||
|
webdotexampledotcomRecordAAAA dns.RR = test.AAAA("web.example.com. 3600 IN AAAA 2001:db8:dead:beef::1:17")
|
||||||
|
wwwdotexampledotcomName string = "www.example.com."
|
||||||
|
wwwdotexampledotcomRecordCNAME dns.RR = test.CNAME("www.example.com. 3600 IN CNAME web.example.com.")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -378,16 +394,23 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "web.example.com.", Qtype: dns.TypeA,
|
Qname: webdotexampledotcomName, Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.A("web.example.com. 3600 IN A 10.0.0.17"),
|
webdotexampledotcomRecordA,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "www.example.com.", Qtype: dns.TypeCNAME,
|
Qname: wwwdotexampledotcomName, Qtype: dns.TypeCNAME,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.CNAME("www.example.com. 3600 IN CNAME web.example.com."),
|
wwwdotexampledotcomRecordCNAME,
|
||||||
test.A("web.example.com. 3600 IN A 10.0.0.17"),
|
webdotexampledotcomRecordA,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Qname: wwwdotexampledotcomName, Qtype: dns.TypeA,
|
||||||
|
Answer: []dns.RR{
|
||||||
|
wwwdotexampledotcomRecordCNAME,
|
||||||
|
webdotexampledotcomRecordA,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -549,16 +572,23 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "web.example.com.", Qtype: dns.TypeAAAA,
|
Qname: webdotexampledotcomName, Qtype: dns.TypeAAAA,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("web.example.com. 3600 IN AAAA 2001:db8:dead:beef::1:17"),
|
webdotexampledotcomRecordAAAA,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "www.example.com.", Qtype: dns.TypeCNAME,
|
Qname: wwwdotexampledotcomName, Qtype: dns.TypeCNAME,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.CNAME("www.example.com. 3600 IN CNAME web.example.com."),
|
wwwdotexampledotcomRecordCNAME,
|
||||||
test.AAAA("web.example.com. 3600 IN AAAA 2001:db8:dead:beef::1:17"),
|
webdotexampledotcomRecordAAAA,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Qname: wwwdotexampledotcomName, Qtype: dns.TypeAAAA,
|
||||||
|
Answer: []dns.RR{
|
||||||
|
wwwdotexampledotcomRecordCNAME,
|
||||||
|
webdotexampledotcomRecordAAAA,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user