Files
go-winio/sd_test.go
T
Amit fd34511314 Switch to Go 1.23 and fix CI failures
Some new upcoming changes require us to use Go 1.23. However, if we switch to Go 1.23 some
new linter errors are showing up. This commit fixes most of the errors and adds an
exclusion for integer overflow errors.

Signed-off-by: Amit <ambarve@microsoft.com>
2025-10-27 09:08:22 -07:00

48 lines
1.2 KiB
Go

//go:build windows
package winio
import (
"errors"
"testing"
"golang.org/x/sys/windows"
)
func TestLookupInvalidSid(t *testing.T) {
_, err := LookupSidByName(".\\weoifjdsklfj")
var aerr *AccountLookupError
if !errors.As(err, &aerr) || !errors.Is(err, windows.ERROR_NONE_MAPPED) {
t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
}
}
func TestLookupInvalidName(t *testing.T) {
_, err := LookupNameBySid("notasid")
var aerr *AccountLookupError
if !errors.As(err, &aerr) || !errors.Is(aerr.Err, windows.ERROR_INVALID_SID) {
t.Fatalf("expected AccountLookupError with ERROR_INVALID_SID got %s", err)
}
}
func TestLookupValidSid(t *testing.T) {
everyone := "S-1-1-0"
name, err := LookupNameBySid(everyone)
if err != nil {
t.Fatalf("expected a valid account name, got %v", err)
}
sid, err := LookupSidByName(name)
if err != nil || sid != everyone {
t.Fatalf("expected %s, got %s, %s", everyone, sid, err)
}
}
func TestLookupEmptyNameFails(t *testing.T) {
_, err := LookupSidByName("")
var aerr *AccountLookupError
if !errors.As(err, &aerr) || !errors.Is(aerr.Err, windows.ERROR_NONE_MAPPED) {
t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
}
}