summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/options_test.go
diff options
context:
space:
mode:
authorinsomniac <insomniacslk@users.noreply.github.com>2018-08-02 16:41:12 -0700
committerGitHub <noreply@github.com>2018-08-02 16:41:12 -0700
commita2315f847b7734cdc5cde2539ed1764a0350068a (patch)
treec7e00b8381272382c2f382b0a75899314e0f3d9c /dhcpv4/options_test.go
parentd84e631005a4bf565884e42639f37d45b9a3c8ab (diff)
parente5d59324bd89596d9a3d88d972936d691d96a96c (diff)
add OptClientArchType (#119)
Diffstat (limited to 'dhcpv4/options_test.go')
-rw-r--r--dhcpv4/options_test.go64
1 files changed, 56 insertions, 8 deletions
diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go
index b3d7605..0268483 100644
--- a/dhcpv4/options_test.go
+++ b/dhcpv4/options_test.go
@@ -25,6 +25,46 @@ func TestParseOption(t *testing.T) {
require.Equal(t, 4, opt.Length(), "Length")
require.Equal(t, option, opt.ToBytes(), "ToBytes")
+ // Option router
+ option = []byte{3, 4, 192, 168, 1, 1}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionRouter, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
+ // Option domain name server
+ option = []byte{6, 4, 192, 168, 1, 1}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionDomainNameServer, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
+ // Option host name
+ option = []byte{12, 4, 't', 'e', 's', 't'}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionHostName, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
+ // Option domain name
+ option = []byte{15, 4, 't', 'e', 's', 't'}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionDomainName, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
+ // Option NTP servers
+ option = []byte{42, 4, 10, 10, 10, 10}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionNTPServers, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
// Requested IP address
option = []byte{50, 4, 1, 2, 3, 4}
opt, err = ParseOption(option)
@@ -41,14 +81,6 @@ func TestParseOption(t *testing.T) {
require.Equal(t, 1, opt.Length(), "Length")
require.Equal(t, option, opt.ToBytes(), "ToBytes")
- // Parameter request list
- option = []byte{55, 3, 5, 53, 61}
- opt, err = ParseOption(option)
- require.NoError(t, err)
- require.Equal(t, OptionParameterRequestList, opt.Code(), "Code")
- require.Equal(t, 3, opt.Length(), "Length")
- require.Equal(t, option, opt.ToBytes(), "ToBytes")
-
// Option server ID
option = []byte{54, 4, 1, 2, 3, 4}
opt, err = ParseOption(option)
@@ -57,6 +89,14 @@ func TestParseOption(t *testing.T) {
require.Equal(t, 4, opt.Length(), "Length")
require.Equal(t, option, opt.ToBytes(), "ToBytes")
+ // Parameter request list
+ option = []byte{55, 3, 5, 53, 61}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionParameterRequestList, opt.Code(), "Code")
+ require.Equal(t, 3, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
// Option max message size
option = []byte{57, 2, 1, 2}
opt, err = ParseOption(option)
@@ -96,6 +136,14 @@ func TestParseOption(t *testing.T) {
require.Equal(t, OptionUserClassInformation, opt.Code(), "Code")
require.Equal(t, 5, opt.Length(), "Length")
require.Equal(t, option, opt.ToBytes(), "ToBytes")
+
+ // Option client system architecture type option
+ option = []byte{93, 4, 't', 'e', 's', 't'}
+ opt, err = ParseOption(option)
+ require.NoError(t, err)
+ require.Equal(t, OptionClientSystemArchitectureType, opt.Code(), "Code")
+ require.Equal(t, 4, opt.Length(), "Length")
+ require.Equal(t, option, opt.ToBytes(), "ToBytes")
}
func TestParseOptionZeroLength(t *testing.T) {