fleet/orbit/pkg/platform/platform_windows_test.go

46 lines
1.4 KiB
Go

//go:build windows
// +build windows
package platform
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUUIDNotPresent(t *testing.T) {
uuidBytes := []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
_, err := isValidUUID(uuidBytes)
assert.NotNil(t, err, "UUID not present: ")
}
func TestUUIDNotSet(t *testing.T) {
uuidBytes := []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
_, err := isValidUUID(uuidBytes)
assert.NotNil(t, err, "UUID not set: ")
}
func TestUUIDInvalidSize(t *testing.T) {
uuidBytes := []byte{0x11, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
_, err := isValidUUID(uuidBytes)
assert.NotNil(t, err, "UUID validation size: ")
}
func TestUUIDValid(t *testing.T) {
uuidBytes := []byte{0x11, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00}
_, err := isValidUUID(uuidBytes)
assert.Nil(t, err, "UUID validation error: ")
}
func TestUUIDStringsIncludedInSectionPayload(t *testing.T) {
payloadWithUUIDAndStrings := []byte{0x11, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x73, 0x6d, 0x62, 0x69, 0x6f, 0x73, 0x00}
_, err := isValidUUID(payloadWithUUIDAndStrings)
assert.Nil(t, err, "UUID validation error: ")
}