Port tests from SkyDNS

This adds *most* of the tests from SkyDNS, things lacking is
the stubzone checking, groups and the trim prefix. These
will be added in subsequent PRs and in separate test files.
This commit is contained in:
Miek Gieben
2016-03-24 17:31:01 +00:00
parent b45208e3e5
commit 4fe39f9e9e
4 changed files with 77 additions and 102 deletions

View File

@@ -197,15 +197,13 @@ func (e Etcd) SRV(zone string, state middleware.State) (records []dns.RR, extra
break
}
// Internal name, we should have some info on them, either v4 or v6
// Clients expect a complete answer, because we are a recursor in their
// view.
// Clients expect a complete answer, because we are a recursor in their view.
state1 := copyState(state, srv.Target, dns.TypeA)
// TODO(both is true here!
addr, e1 := e.A(zone, state1, nil)
if e1 == nil {
extra = append(extra, addr...)
}
// e.AAA(zone, state1, nil) as well...
// e.AAA(zone, state1, nil) as well...?
case ip.To4() != nil:
serv.Host = e.Domain(serv.Key)
srv := serv.NewSRV(state.QName(), weight)
@@ -264,7 +262,6 @@ func (e Etcd) MX(zone string, state middleware.State) (records []dns.RR, extra [
break
}
// Internal name
// both is true here as well
state1 := copyState(state, mx.Mx, dns.TypeA)
addr, e1 := e.A(zone, state1, nil)
if e1 == nil {
@@ -319,11 +316,15 @@ func (e Etcd) TXT(zone string, state middleware.State) (records []dns.RR, err er
}
// synthesis a SOA Record.
// TODO(miek): finish
func (e Etcd) SOA(zone string, state middleware.State) *dns.SOA {
header := dns.RR_Header{Name: zone, Rrtype: dns.TypeSOA, Ttl: 300, Class: dns.ClassINET}
return &dns.SOA{Hdr: header, Mbox: "hostmaster." + zone, Ns: "ns.dns." + zone}
}
// TODO(miek): NS records, DS and DNSKEY ones...? prolly so that the signing will
// work...
func isDuplicateCNAME(r *dns.CNAME, records []dns.RR) bool {
for _, rec := range records {
if v, ok := rec.(*dns.CNAME); ok {
@@ -336,7 +337,7 @@ func isDuplicateCNAME(r *dns.CNAME, records []dns.RR) bool {
}
func copyState(state middleware.State, target string, typ uint16) middleware.State {
state1 := state
state1 := middleware.State{W: state.W, Req: state.Req.Copy()}
state1.Req.Question[0] = dns.Question{dns.Fqdn(target), dns.ClassINET, typ}
return state1
}