diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-06-10 15:40:53 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-06-10 15:40:53 +0100 |
commit | 784b93fe8bb3034a7f75272d6259aca86fd710da (patch) | |
tree | 01103e8f1362278e81ff497fcddca02b764b4548 /dhcpv6/utils_test.go | |
parent | 6e1fa7be283c80ba513d4c88f0dba466b5aab32d (diff) |
add IsNetboot and IsUsingUEFI (#70)
Diffstat (limited to 'dhcpv6/utils_test.go')
-rw-r--r-- | dhcpv6/utils_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dhcpv6/utils_test.go b/dhcpv6/utils_test.go new file mode 100644 index 0000000..2373691 --- /dev/null +++ b/dhcpv6/utils_test.go @@ -0,0 +1,51 @@ +package dhcpv6 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestIsNetboot(t *testing.T) { + msg1 := DHCPv6Message{} + require.False(t, IsNetboot(&msg1)) + + msg2 := DHCPv6Message{} + optro := OptRequestedOption{} + optro.AddRequestedOption(OPT_BOOTFILE_URL) + msg2.AddOption(&optro) + require.True(t, IsNetboot(&msg2)) + + msg3 := DHCPv6Message{} + optbf := OptBootFileURL{} + msg3.AddOption(&optbf) + require.True(t, IsNetboot(&msg3)) +} + +func TestIsUsingUEFIArchTypeTrue(t *testing.T) { + msg := DHCPv6Message{} + opt := OptClientArchType{ArchType: EFI_BC} + msg.AddOption(&opt) + require.True(t, IsUsingUEFI(&msg)) +} + +func TestIsUsingUEFIArchTypeFalse(t *testing.T) { + msg := DHCPv6Message{} + opt := OptClientArchType{ArchType: INTEL_X86PC} + msg.AddOption(&opt) + require.False(t, IsUsingUEFI(&msg)) +} + +func TestIsUsingUEFIUserClassTrue(t *testing.T) { + msg := DHCPv6Message{} + opt := OptUserClass{UserClasses: [][]byte{[]byte("ipxeUEFI")}} + msg.AddOption(&opt) + require.True(t, IsUsingUEFI(&msg)) +} + +func TestIsUsingUEFIUserClassFalse(t *testing.T) { + msg := DHCPv6Message{} + opt := OptUserClass{UserClasses: [][]byte{[]byte("ipxeLegacy")}} + msg.AddOption(&opt) + require.False(t, IsUsingUEFI(&msg)) +} |