diff options
author | insomniac <insomniacslk@users.noreply.github.com> | 2018-05-10 11:52:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 11:52:34 +0200 |
commit | eab1c08cbc637f5d370bf84da1feba8673fb7cc3 (patch) | |
tree | 8398d039145e3a390a51ad3983d94d38cd8a48fd /dhcpv6/option_dnsrecursivenameserver_test.go | |
parent | f371c3544b9bdfd70ceab7d96895e6069cd46462 (diff) |
OptDNSRecursiveNameServer gets public fields and tests, removes setter and getter (#62)
Diffstat (limited to 'dhcpv6/option_dnsrecursivenameserver_test.go')
-rw-r--r-- | dhcpv6/option_dnsrecursivenameserver_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dhcpv6/option_dnsrecursivenameserver_test.go b/dhcpv6/option_dnsrecursivenameserver_test.go new file mode 100644 index 0000000..85bb982 --- /dev/null +++ b/dhcpv6/option_dnsrecursivenameserver_test.go @@ -0,0 +1,35 @@ +package dhcpv6 + +import ( + "net" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParseOptDNSRecursiveNameServer(t *testing.T) { + data := []byte{ + 0x2a, 0x03, 0x28, 0x80, 0xff, 0xfe, 0x00, 0x0c, 0xfa, 0xce, 0xb0, 0x0c, 0x00, 0x00, 0x00, 0x35, + } + expected := []net.IP{ + net.IP(data), + } + opt, err := ParseOptDNSRecursiveNameServer(data) + require.NoError(t, err) + require.Equal(t, opt.NameServers, expected) + require.Equal(t, opt.Length(), 16) +} + +func TestOptDNSRecursiveNameServerToBytes(t *testing.T) { + ns1 := net.ParseIP("2a03:2880:fffe:c:face:b00c:0:35") + ns2 := net.ParseIP("2001:4860:4860::8888") + nameservers := []net.IP{ns1, ns2} + expected := []byte{ + 0, 23, // DNS_RECURSIVE_NAME_SERVER + 0, 32, // length + } + expected = append(expected, []byte(ns1)...) + expected = append(expected, []byte(ns2)...) + opt := OptDNSRecursiveNameServer{NameServers: nameservers} + require.Equal(t, opt.ToBytes(), expected) +} |