plugin/file: rework outgoing axfr (#3227)

* plugin/file: rework outgoing axfr

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix test

Signed-off-by: Miek Gieben <miek@miek.nl>

* Actually properly test xfr

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix test

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2019-08-30 13:47:27 +01:00
committed by GitHub
parent b8a0b52a5e
commit 94930d20ea
5 changed files with 70 additions and 54 deletions

View File

@@ -129,9 +129,9 @@ func TestAutoAXFR(t *testing.T) {
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
}
udp, _ := CoreDNSServerPorts(i, 0)
if udp == "" {
t.Fatal("Could not get UDP listening port")
_, tcp := CoreDNSServerPorts(i, 0)
if tcp == "" {
t.Fatal("Could not get TCP listening port")
}
defer i.Stop()
@@ -142,14 +142,20 @@ func TestAutoAXFR(t *testing.T) {
time.Sleep(1100 * time.Millisecond) // wait for it to be picked up
tr := new(dns.Transfer)
m := new(dns.Msg)
m.SetAxfr("example.org.")
resp, err := dns.Exchange(m, udp)
c, err := tr.In(m, tcp)
if err != nil {
t.Fatal("Expected to receive reply, but didn't")
}
if len(resp.Answer) != 5 {
t.Fatalf("Expected response with %d RRs, got %d", 5, len(resp.Answer))
l := 0
for e := range c {
l += len(e.RR)
}
if l != 5 {
t.Fatalf("Expected response with %d RRs, got %d", 5, l)
}
}