diff options
author | Owen Mooney <owenmooney@fb.com> | 2018-07-24 06:41:32 -0700 |
---|---|---|
committer | Owen Mooney <owenmooney@fb.com> | 2018-07-24 06:41:32 -0700 |
commit | 6c61e813f2a9a8df16c93d8b2511686ee67942c1 (patch) | |
tree | 1b335e26d9ea781a51782a05be695537c312ed54 /dhcpv4/option_userclass_test.go | |
parent | dbec521a557fffd49f76daab6fc27e0ab77409be (diff) |
Return error on empty User Class
Diffstat (limited to 'dhcpv4/option_userclass_test.go')
-rw-r--r-- | dhcpv4/option_userclass_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/dhcpv4/option_userclass_test.go b/dhcpv4/option_userclass_test.go index cbfd38b..5b71ea5 100644 --- a/dhcpv4/option_userclass_test.go +++ b/dhcpv4/option_userclass_test.go @@ -90,3 +90,33 @@ func TestParseOptUserClassShorterTotalLength(t *testing.T) { _, err := ParseOptUserClass(expected) require.Error(t, err) } + +func TestOptUserClassLength(t *testing.T) { + expected := []byte{ + 77, 10, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 'X', + } + opt, err := ParseOptUserClass(expected) + require.NoError(t, err) + require.Equal(t, 10, opt.Length()) +} + +func TestParseOptUserClassZeroLength(t *testing.T) { + expected := []byte{ + 77, 1, 0, 0, + } + _, err := ParseOptUserClass(expected) + require.Error(t, err) +} + +func TestParseOptUserClassMultipleWithZeroLength(t *testing.T) { + expected := []byte{ + 77, 12, 10, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 0, + } + _, err := ParseOptUserClass(expected) + require.Error(t, err) +} + +func TestOptUserClassCode(t *testing.T) { + opt := OptUserClass{} + require.Equal(t, OptionUserClassInformation, opt.Code()) +} |