2019-11-19 10:00:20 -07:00
|
|
|
package nebula
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/miekg/dns"
|
2024-04-11 20:44:36 -06:00
|
|
|
"github.com/slackhq/nebula/config"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-11-19 10:00:20 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParsequery(t *testing.T) {
|
|
|
|
//TODO: This test is basically pointless
|
|
|
|
hostMap := &HostMap{}
|
|
|
|
ds := newDnsRecords(hostMap)
|
|
|
|
ds.Add("test.com.com", "1.2.3.4")
|
|
|
|
|
|
|
|
m := new(dns.Msg)
|
|
|
|
m.SetQuestion("test.com.com", dns.TypeA)
|
|
|
|
|
|
|
|
//parseQuery(m)
|
|
|
|
}
|
2024-04-11 20:44:36 -06:00
|
|
|
|
|
|
|
func Test_getDnsServerAddr(t *testing.T) {
|
|
|
|
c := config.NewC(nil)
|
|
|
|
|
|
|
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
|
|
|
"dns": map[interface{}]interface{}{
|
|
|
|
"host": "0.0.0.0",
|
|
|
|
"port": "1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
assert.Equal(t, "0.0.0.0:1", getDnsServerAddr(c))
|
|
|
|
|
|
|
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
|
|
|
"dns": map[interface{}]interface{}{
|
|
|
|
"host": "::",
|
|
|
|
"port": "1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
|
|
|
|
|
|
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
|
|
|
"dns": map[interface{}]interface{}{
|
|
|
|
"host": "[::]",
|
|
|
|
"port": "1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
|
|
|
|
|
|
|
// Make sure whitespace doesn't mess us up
|
|
|
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
|
|
|
"dns": map[interface{}]interface{}{
|
|
|
|
"host": "[::] ",
|
|
|
|
"port": "1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
|
|
|
}
|