github.com/slackhq/nebula@v1.9.0/dns_server_test.go (about) 1 package nebula 2 3 import ( 4 "testing" 5 6 "github.com/miekg/dns" 7 "github.com/slackhq/nebula/config" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestParsequery(t *testing.T) { 12 //TODO: This test is basically pointless 13 hostMap := &HostMap{} 14 ds := newDnsRecords(hostMap) 15 ds.Add("test.com.com", "1.2.3.4") 16 17 m := new(dns.Msg) 18 m.SetQuestion("test.com.com", dns.TypeA) 19 20 //parseQuery(m) 21 } 22 23 func Test_getDnsServerAddr(t *testing.T) { 24 c := config.NewC(nil) 25 26 c.Settings["lighthouse"] = map[interface{}]interface{}{ 27 "dns": map[interface{}]interface{}{ 28 "host": "0.0.0.0", 29 "port": "1", 30 }, 31 } 32 assert.Equal(t, "0.0.0.0:1", getDnsServerAddr(c)) 33 34 c.Settings["lighthouse"] = map[interface{}]interface{}{ 35 "dns": map[interface{}]interface{}{ 36 "host": "::", 37 "port": "1", 38 }, 39 } 40 assert.Equal(t, "[::]:1", getDnsServerAddr(c)) 41 42 c.Settings["lighthouse"] = map[interface{}]interface{}{ 43 "dns": map[interface{}]interface{}{ 44 "host": "[::]", 45 "port": "1", 46 }, 47 } 48 assert.Equal(t, "[::]:1", getDnsServerAddr(c)) 49 50 // Make sure whitespace doesn't mess us up 51 c.Settings["lighthouse"] = map[interface{}]interface{}{ 52 "dns": map[interface{}]interface{}{ 53 "host": "[::] ", 54 "port": "1", 55 }, 56 } 57 assert.Equal(t, "[::]:1", getDnsServerAddr(c)) 58 }