File: dns_server_test.go

package info (click to toggle)
nebula 1.9.3%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,772 kB
  • sloc: makefile: 183; sh: 100
file content (58 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package nebula

import (
	"testing"

	"github.com/miekg/dns"
	"github.com/slackhq/nebula/config"
	"github.com/stretchr/testify/assert"
)

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)
}

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))
}