"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/querylog/qlog_test.go" between
AdGuardHome-0.104.1.tar.gz and AdGuardHome-0.104.3.tar.gz

About: AdGuard Home is a network-wide ads & trackers blocking DNS server. It operates as a DNS server that re-routes tracking domains to a "black hole," thus preventing your devices from connecting to those servers.

qlog_test.go  (AdGuardHome-0.104.1):qlog_test.go  (AdGuardHome-0.104.3)
package querylog package querylog
import ( import (
"net" "net"
"os" "os"
"testing" "testing"
"github.com/AdguardTeam/dnsproxy/proxyutil" "github.com/AdguardTeam/dnsproxy/proxyutil"
"github.com/AdguardTeam/AdGuardHome/internal/dnsfilter" "github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
"github.com/AdguardTeam/AdGuardHome/internal/testutil"
"github.com/miekg/dns" "github.com/miekg/dns"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestMain(m *testing.M) {
testutil.DiscardLogOutput(m)
}
func prepareTestDir() string { func prepareTestDir() string {
const dir = "./agh-test" const dir = "./agh-test"
_ = os.RemoveAll(dir) _ = os.RemoveAll(dir)
_ = os.MkdirAll(dir, 0755) _ = os.MkdirAll(dir, 0755)
return dir return dir
} }
// Check adding and loading (with filtering) entries from disk and memory // Check adding and loading (with filtering) entries from disk and memory
func TestQueryLog(t *testing.T) { func TestQueryLog(t *testing.T) {
conf := Config{ conf := Config{
skipping to change at line 229 skipping to change at line 234
a := dns.Msg{} a := dns.Msg{}
a.Question = append(a.Question, q.Question[0]) a.Question = append(a.Question, q.Question[0])
answer := new(dns.A) answer := new(dns.A)
answer.Hdr = dns.RR_Header{ answer.Hdr = dns.RR_Header{
Name: q.Question[0].Name, Name: q.Question[0].Name,
Rrtype: dns.TypeA, Rrtype: dns.TypeA,
Class: dns.ClassINET, Class: dns.ClassINET,
} }
answer.A = net.ParseIP(answerStr) answer.A = net.ParseIP(answerStr)
a.Answer = append(a.Answer, answer) a.Answer = append(a.Answer, answer)
res := dnsfilter.Result{} res := dnsfilter.Result{
IsFiltered: true,
Rule: "SomeRule",
Reason: dnsfilter.ReasonRewrite,
ServiceName: "SomeService",
FilterID: 1,
}
params := AddParams{ params := AddParams{
Question: &q, Question: &q,
Answer: &a, Answer: &a,
Result: &res, OrigAnswer: &a,
ClientIP: net.ParseIP(client), Result: &res,
Upstream: "upstream", ClientIP: net.ParseIP(client),
Upstream: "upstream",
} }
l.Add(params) l.Add(params)
} }
func assertLogEntry(t *testing.T, entry *logEntry, host, answer, client string) bool { func assertLogEntry(t *testing.T, entry *logEntry, host, answer, client string) bool {
assert.Equal(t, host, entry.QHost) assert.Equal(t, host, entry.QHost)
assert.Equal(t, client, entry.IP) assert.Equal(t, client, entry.IP)
assert.Equal(t, "A", entry.QType) assert.Equal(t, "A", entry.QType)
assert.Equal(t, "IN", entry.QClass) assert.Equal(t, "IN", entry.QClass)
 End of changes. 4 change blocks. 
6 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)