* refactor

This commit is contained in:
Simon Zolin 2020-01-10 15:49:09 +03:00
parent 0ef8e5cdae
commit 3b9d758510
1 changed files with 6 additions and 18 deletions

View File

@ -365,35 +365,23 @@ func TestBlockCNAME(t *testing.T) {
// 'badhost' has a canonical name 'null.example.org' which is blocked by filters: // 'badhost' has a canonical name 'null.example.org' which is blocked by filters:
// response is blocked // response is blocked
req := dns.Msg{} req := createTestMessage("badhost.")
req.Id = dns.Id() reply, err := dns.Exchange(req, addr.String())
req.Question = []dns.Question{
{Name: "badhost.", Qtype: dns.TypeA, Qclass: dns.ClassINET},
}
reply, err := dns.Exchange(&req, addr.String())
assert.True(t, err == nil) assert.True(t, err == nil)
assert.True(t, reply.Rcode == dns.RcodeNameError) assert.True(t, reply.Rcode == dns.RcodeNameError)
// 'whitelist.example.org' has a canonical name 'null.example.org' which is blocked by filters // 'whitelist.example.org' has a canonical name 'null.example.org' which is blocked by filters
// but 'whitelist.example.org' is in a whitelist: // but 'whitelist.example.org' is in a whitelist:
// response isn't blocked // response isn't blocked
req = dns.Msg{} req = createTestMessage("whitelist.example.org.")
req.Id = dns.Id() reply, err = dns.Exchange(req, addr.String())
req.Question = []dns.Question{
{Name: "whitelist.example.org.", Qtype: dns.TypeA, Qclass: dns.ClassINET},
}
reply, err = dns.Exchange(&req, addr.String())
assert.True(t, err == nil) assert.True(t, err == nil)
assert.True(t, reply.Rcode == dns.RcodeSuccess) 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: // 'example.org' has a canonical name 'cname1' with IP 127.0.0.255 which is blocked by filters:
// response is blocked // response is blocked
req = dns.Msg{} req = createTestMessage("example.org.")
req.Id = dns.Id() reply, err = dns.Exchange(req, addr.String())
req.Question = []dns.Question{
{Name: "example.org.", Qtype: dns.TypeA, Qclass: dns.ClassINET},
}
reply, err = dns.Exchange(&req, addr.String())
assert.True(t, err == nil) assert.True(t, err == nil)
assert.True(t, reply.Rcode == dns.RcodeNameError) assert.True(t, reply.Rcode == dns.RcodeNameError)