summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_dnsrecursivenameserver_test.go
diff options
context:
space:
mode:
authorDavid Barr <38654497+davebarrau@users.noreply.github.com>2018-10-12 11:09:04 +1100
committerinsomniac <insomniacslk@users.noreply.github.com>2018-10-11 17:09:04 -0700
commitdc01165c86340093eacf62c0856ae4e2164a4845 (patch)
tree9ca76ae4103c3e63cd86620fdec230e5cfe5b78d /dhcpv6/option_dnsrecursivenameserver_test.go
parentee671d361777cc640550bab38cc6b0d412396f80 (diff)
Add some more DHCPv6 option tests. (#171)
* Add some more DHCPv6 option tests. * Remove AddRequestedOption() duplicate detection test due to failing on Go 1.9
Diffstat (limited to 'dhcpv6/option_dnsrecursivenameserver_test.go')
-rw-r--r--dhcpv6/option_dnsrecursivenameserver_test.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/dhcpv6/option_dnsrecursivenameserver_test.go b/dhcpv6/option_dnsrecursivenameserver_test.go
index 71fe6d3..1a56797 100644
--- a/dhcpv6/option_dnsrecursivenameserver_test.go
+++ b/dhcpv6/option_dnsrecursivenameserver_test.go
@@ -16,8 +16,10 @@ func TestParseOptDNSRecursiveNameServer(t *testing.T) {
}
opt, err := ParseOptDNSRecursiveNameServer(data)
require.NoError(t, err)
- require.Equal(t, opt.NameServers, expected)
- require.Equal(t, opt.Length(), 16)
+ require.Equal(t, expected, opt.NameServers)
+ require.Equal(t, OptionDNSRecursiveNameServer, opt.Code())
+ require.Equal(t, 16, opt.Length())
+ require.Contains(t, opt.String(), "nameservers=[2a03:2880:fffe:c:face:b00c:0:35]", "String() should contain the correct nameservers output")
}
func TestOptDNSRecursiveNameServerToBytes(t *testing.T) {
@@ -31,5 +33,13 @@ func TestOptDNSRecursiveNameServerToBytes(t *testing.T) {
expected = append(expected, []byte(ns1)...)
expected = append(expected, []byte(ns2)...)
opt := OptDNSRecursiveNameServer{NameServers: nameservers}
- require.Equal(t, opt.ToBytes(), expected)
+ require.Equal(t, expected, opt.ToBytes())
+}
+
+func TestParseOptDNSRecursiveNameServerParseBogusNameserver(t *testing.T) {
+ data := []byte{
+ 0x2a, 0x03, 0x28, 0x80, 0xff, 0xfe, 0x00, 0x0c, // invalid IPv6 address
+ }
+ _, err := ParseOptDNSRecursiveNameServer(data)
+ require.Error(t, err, "An invalid nameserver IPv6 address should return an error")
}