diff options
author | MikoĊaj Walczak <mikiwalczak+github@gmail.com> | 2018-07-11 13:32:51 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-07-11 13:32:51 +0100 |
commit | 34154e71da6f5b4527809dc0babdefcbd262281c (patch) | |
tree | 1c483f4c6422247e1d1b8099951ec943a4c0729f /dhcpv6/dhcpv6_test.go | |
parent | ab01f8d86f0edc6873008db8983ffa34363db3a5 (diff) |
NewSolicitWithCID for DHCPv6 (#76)
Diffstat (limited to 'dhcpv6/dhcpv6_test.go')
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index f8ec76d..3db4cee 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -1,8 +1,10 @@ package dhcpv6 import ( + "net" "testing" + "github.com/insomniacslk/dhcp/iana" "github.com/stretchr/testify/require" ) @@ -139,5 +141,37 @@ func TestNewReplyFromDHCPv6Message(t *testing.T) { require.Error(t, err) } +func TestNewSolicitWithCID(t *testing.T) { + hwAddr, err := net.ParseMAC("24:0A:9E:9F:EB:2B") + require.NoError(t, err) + + duid := Duid{ + Type: DUID_LL, + HwType: iana.HwTypeEthernet, + LinkLayerAddr: hwAddr, + } + + s, err := NewSolicitWithCID(duid) + require.NoError(t, err) + + require.Equal(t, s.Type(), SOLICIT) + // Check CID + cidOption := s.GetOneOption(OPTION_CLIENTID) + require.NotNil(t, cidOption) + cid, ok := cidOption.(*OptClientId) + require.True(t, ok) + require.Equal(t, cid.Cid, duid) + + // Check ORO + oroOption := s.GetOneOption(OPTION_ORO) + require.NotNil(t, oroOption) + oro, ok := oroOption.(*OptRequestedOption) + require.True(t, ok) + opts := oro.RequestedOptions() + require.Contains(t, opts, DNS_RECURSIVE_NAME_SERVER) + require.Contains(t, opts, DOMAIN_SEARCH_LIST) + require.Equal(t, len(opts), 2) +} + // TODO test NewSolicit // test String and Summary |