mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Fix test data.
This commit is contained in:
@@ -6,35 +6,32 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/bluele/gcache"
|
||||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
func TestprocessDNSMessageMultipleCNAME(t *testing.T) {
|
||||
func TestProcessDNSMessageMultipleCNAME(t *testing.T) {
|
||||
domain := "dummy.com"
|
||||
question := layers.DNSQuestion{
|
||||
Name: []byte(domain),
|
||||
Type: layers.DNSTypeA,
|
||||
Name: []byte(domain),
|
||||
Type: layers.DNSTypeA,
|
||||
Class: layers.DNSClassIN,
|
||||
}
|
||||
|
||||
ipAddressCNAME := "127.0.0.1"
|
||||
ipAddress := "127.0.1.1"
|
||||
answers := []layers.DNSResourceRecord{
|
||||
layers.DNSResourceRecord{
|
||||
Name: []byte("api.dummy.com"),
|
||||
CNAME: []byte("api.dummy.com"),
|
||||
Type: layers.DNSTypeCNAME,
|
||||
Class: layers.DNSClassIN,
|
||||
},
|
||||
layers.DNSResourceRecord{
|
||||
Name: []byte("star.c10r.dummy.com"),
|
||||
CNAME: []byte("star.c10r.dummy.com"),
|
||||
Type: layers.DNSTypeCNAME,
|
||||
Class: layers.DNSClassIN,
|
||||
},
|
||||
layers.DNSResourceRecord{
|
||||
Name: []byte("dummy.com"),
|
||||
Type: layers.DNSTypeA,
|
||||
Class: layers.DNSClassIN,
|
||||
IP: net.ParseIP(ipAddress),
|
||||
},
|
||||
layers.DNSResourceRecord{
|
||||
Name: []byte("star.c10r.dummy.com"),
|
||||
Type: layers.DNSTypeA,
|
||||
@@ -44,12 +41,15 @@ func TestprocessDNSMessageMultipleCNAME(t *testing.T) {
|
||||
}
|
||||
|
||||
dns := layers.DNS{
|
||||
QR: true,
|
||||
ResponseCode: layers.DNSResponseCodeNoErr,
|
||||
Questions: []layers.DNSQuestion{question},
|
||||
Answers: answers,
|
||||
}
|
||||
|
||||
snooper := &DNSSnooper{}
|
||||
snooper := &DNSSnooper{
|
||||
reverseDNSCache: gcache.New(4).LRU().Build(),
|
||||
}
|
||||
|
||||
snooper.processDNSMessage(&dns)
|
||||
|
||||
@@ -62,14 +62,4 @@ func TestprocessDNSMessageMultipleCNAME(t *testing.T) {
|
||||
if _, ok := existingDomains.(map[string]struct{})[domain]; !ok {
|
||||
t.Errorf("Domain %s should have been inserted", domain)
|
||||
}
|
||||
|
||||
existingDomains, err = snooper.reverseDNSCache.Get(ipAddress)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("A domain should have been inserted for the given IP:%v", err)
|
||||
}
|
||||
|
||||
if _, ok := existingDomains.(map[string]struct{})[domain]; !ok {
|
||||
t.Errorf("Domain %s should have been inserted", domain)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user