Files
Reims-Go/internal/host/elevate_windows_test.go
T

36 lines
866 B
Go

//go:build windows
package host
import (
"runtime"
"testing"
"unsafe"
)
func TestShellExecuteInfoLayoutMatchesWin32(t *testing.T) {
if runtime.GOARCH != "amd64" {
t.Skip("layout size is asserted for amd64")
}
if got := unsafe.Sizeof(shellExecuteInfoW{}); got != 112 {
t.Fatalf("SHELLEXECUTEINFOW is %d bytes, want 112", got)
}
}
func TestHyperVAdminsGroupResolvesFromTheWellKnownSID(t *testing.T) {
name, err := hyperVAdminsGroupName()
if err != nil {
t.Skipf("this Windows has no Hyper-V Administrators group: %v", err)
}
if name == "" {
t.Fatal("the group name is empty")
}
}
func TestExecuteElevatedActionValidatesTheAccountBeforeRunning(t *testing.T) {
res, err := ExecuteElevatedAction(t.Context(), ElevateHyperVAddAdminGroup, "alice & calc")
if err == nil || res.OK {
t.Fatalf("an unsafe account name ran: %+v, %v", res, err)
}
}