summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/modifiers_test.go
diff options
context:
space:
mode:
authorOwen Mooney <mooneyow@tcd.ie>2018-08-10 13:33:46 +0100
committerinsomniac <insomniacslk@users.noreply.github.com>2018-08-10 05:33:46 -0700
commit5207d76712250f33111c546d9ace98336d616bfc (patch)
tree734bc4ffa5152980dbf32d4d7c1fca37e9c4d7ed /dhcpv4/modifiers_test.go
parenta2315f847b7734cdc5cde2539ed1764a0350068a (diff)
Added modifier for netbootv4 (#124)
Diffstat (limited to 'dhcpv4/modifiers_test.go')
-rw-r--r--dhcpv4/modifiers_test.go57
1 files changed, 56 insertions, 1 deletions
diff --git a/dhcpv4/modifiers_test.go b/dhcpv4/modifiers_test.go
index 2e249ee..2f0e1ed 100644
--- a/dhcpv4/modifiers_test.go
+++ b/dhcpv4/modifiers_test.go
@@ -8,7 +8,62 @@ import (
func TestUserClassModifier(t *testing.T) {
d, _ := New()
- userClass := WithUserClass([]byte("linuxboot"))
+ userClass := WithUserClass([]byte("linuxboot"), false)
d = userClass(d)
+ expected := []byte{
+ 77, // OptionUserClass
+ 9, // length
+ 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
+ }
require.Equal(t, "User Class Information -> linuxboot", d.options[0].String())
+ require.Equal(t, expected, d.options[0].ToBytes())
+}
+
+func TestUserClassModifierRFC(t *testing.T) {
+ d, _ := New()
+ userClass := WithUserClass([]byte("linuxboot"), true)
+ d = userClass(d)
+ expected := []byte{
+ 77, // OptionUserClass
+ 10, // length
+ 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
+ }
+ require.Equal(t, "User Class Information -> linuxboot", d.options[0].String())
+ require.Equal(t, expected, d.options[0].ToBytes())
+}
+
+func TestWithNetboot(t *testing.T) {
+ d, _ := New()
+ d = WithNetboot(d)
+ require.Equal(t, "Parameter Request List -> [TFTP Server Name, Bootfile Name]", d.options[0].String())
+}
+
+func TestWithNetbootExistingTFTP(t *testing.T) {
+ d, _ := New()
+ OptParams := &OptParameterRequestList{
+ RequestedOpts: []OptionCode{OptionTFTPServerName},
+ }
+ d.AddOption(OptParams)
+ d = WithNetboot(d)
+ require.Equal(t, "Parameter Request List -> [TFTP Server Name, Bootfile Name]", d.options[0].String())
+}
+
+func TestWithNetbootExistingBootfileName(t *testing.T) {
+ d, _ := New()
+ OptParams := &OptParameterRequestList{
+ RequestedOpts: []OptionCode{OptionBootfileName},
+ }
+ d.AddOption(OptParams)
+ d = WithNetboot(d)
+ require.Equal(t, "Parameter Request List -> [Bootfile Name, TFTP Server Name]", d.options[0].String())
+}
+
+func TestWithNetbootExistingBoth(t *testing.T) {
+ d, _ := New()
+ OptParams := &OptParameterRequestList{
+ RequestedOpts: []OptionCode{OptionBootfileName, OptionTFTPServerName},
+ }
+ d.AddOption(OptParams)
+ d = WithNetboot(d)
+ require.Equal(t, "Parameter Request List -> [Bootfile Name, TFTP Server Name]", d.options[0].String())
}