sd_test.go 723 B

1234567891011121314151617181920212223242526
  1. package winio
  2. import "testing"
  3. func TestLookupInvalidSid(t *testing.T) {
  4. _, err := LookupSidByName(".\\weoifjdsklfj")
  5. aerr, ok := err.(*AccountLookupError)
  6. if !ok || aerr.Err != cERROR_NONE_MAPPED {
  7. t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
  8. }
  9. }
  10. func TestLookupValidSid(t *testing.T) {
  11. sid, err := LookupSidByName("Everyone")
  12. if err != nil || sid != "S-1-1-0" {
  13. t.Fatalf("expected S-1-1-0, got %s, %s", sid, err)
  14. }
  15. }
  16. func TestLookupEmptyNameFails(t *testing.T) {
  17. _, err := LookupSidByName(".\\weoifjdsklfj")
  18. aerr, ok := err.(*AccountLookupError)
  19. if !ok || aerr.Err != cERROR_NONE_MAPPED {
  20. t.Fatalf("expected AccountLookupError with ERROR_NONE_MAPPED, got %s", err)
  21. }
  22. }