diff options
author | Owen Mooney <mooneyow@tcd.ie> | 2018-08-01 20:42:28 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-01 20:42:28 +0100 |
commit | 40474d58d9e4302b97e535e199e79ad1c63ade06 (patch) | |
tree | 2dcdac1d0d50d3f1938d5707a6d161f48ec24b87 /dhcpv4/option_userclass_test.go | |
parent | 85e86a8adb8f51277e8e9ceb1d423270dd2fffac (diff) |
Parse non-RFC compliant user class (#114)
Diffstat (limited to 'dhcpv4/option_userclass_test.go')
-rw-r--r-- | dhcpv4/option_userclass_test.go | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/dhcpv4/option_userclass_test.go b/dhcpv4/option_userclass_test.go index 492cabd..02b6f94 100644 --- a/dhcpv4/option_userclass_test.go +++ b/dhcpv4/option_userclass_test.go @@ -38,6 +38,26 @@ func TestParseOptUserClassNone(t *testing.T) { require.Error(t, err) } +func TestParseOptUserClassMicrosoft(t *testing.T) { + expected := []byte{ + 77, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', + } + opt, err := ParseOptUserClass(expected) + require.NoError(t, err) + require.Equal(t, 1, len(opt.UserClasses)) + require.Equal(t, []byte("linuxboot"), opt.UserClasses[0]) +} + +func TestParseOptUserClassMicrosoftLongerThanLength(t *testing.T) { + expected := []byte{ + 77, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 'X', + } + opt, err := ParseOptUserClass(expected) + require.NoError(t, err) + require.Equal(t, 1, len(opt.UserClasses)) + require.Equal(t, []byte("linuxboot"), opt.UserClasses[0]) +} + func TestParseOptUserClass(t *testing.T) { expected := []byte{ 77, 10, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', @@ -75,14 +95,6 @@ func TestParseOptUserClassLongerThanLength(t *testing.T) { require.Equal(t, []byte("linuxboot"), opt.UserClasses[0]) } -func TestParseOptUserClassShorterThanLength(t *testing.T) { - expected := []byte{ - 77, 10, 10, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', - } - _, err := ParseOptUserClass(expected) - require.Error(t, err) -} - func TestParseOptUserClassShorterTotalLength(t *testing.T) { expected := []byte{ 77, 11, 10, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', |