From 3b9d758510cd65e483524de1e698076326950ab0 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Fri, 10 Jan 2020 15:49:09 +0300 Subject: [PATCH] * refactor --- dnsforward/dnsforward_test.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/dnsforward/dnsforward_test.go b/dnsforward/dnsforward_test.go index 5a9d8434..53803c78 100644 --- a/dnsforward/dnsforward_test.go +++ b/dnsforward/dnsforward_test.go @@ -365,35 +365,23 @@ func TestBlockCNAME(t *testing.T) { // 'badhost' has a canonical name 'null.example.org' which is blocked by filters: // response is blocked - req := dns.Msg{} - req.Id = dns.Id() - req.Question = []dns.Question{ - {Name: "badhost.", Qtype: dns.TypeA, Qclass: dns.ClassINET}, - } - reply, err := dns.Exchange(&req, addr.String()) + req := createTestMessage("badhost.") + reply, err := dns.Exchange(req, addr.String()) assert.True(t, err == nil) assert.True(t, reply.Rcode == dns.RcodeNameError) // 'whitelist.example.org' has a canonical name 'null.example.org' which is blocked by filters // but 'whitelist.example.org' is in a whitelist: // response isn't blocked - req = dns.Msg{} - req.Id = dns.Id() - req.Question = []dns.Question{ - {Name: "whitelist.example.org.", Qtype: dns.TypeA, Qclass: dns.ClassINET}, - } - reply, err = dns.Exchange(&req, addr.String()) + req = createTestMessage("whitelist.example.org.") + reply, err = dns.Exchange(req, addr.String()) assert.True(t, err == nil) assert.True(t, reply.Rcode == dns.RcodeSuccess) // 'example.org' has a canonical name 'cname1' with IP 127.0.0.255 which is blocked by filters: // response is blocked - req = dns.Msg{} - req.Id = dns.Id() - req.Question = []dns.Question{ - {Name: "example.org.", Qtype: dns.TypeA, Qclass: dns.ClassINET}, - } - reply, err = dns.Exchange(&req, addr.String()) + req = createTestMessage("example.org.") + reply, err = dns.Exchange(req, addr.String()) assert.True(t, err == nil) assert.True(t, reply.Rcode == dns.RcodeNameError)