-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathldapgrouputils_test.go
47 lines (41 loc) · 1.06 KB
/
ldapgrouputils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"testing"
)
var user1 = LDAPUserObject{
"[email protected],o=com,dc=mozilla",
"testing",
[]string{},
[]byte{},
}
var group1 = []LDAPUserObject{user1}
func TestUserInGroup(t *testing.T) {
username := "testing"
if UserInGroup("testing", group1) == false {
t.Errorf("user %s not found in group", username)
}
if UserInGroup("unknown", group1) == true {
t.Errorf("user %s found in group", username)
}
}
func TestGetLDAPUserObjectFromGroupUserFound(t *testing.T) {
username := "testing"
retUser, found := GetLDAPUserObjectFromGroup(username, group1)
if found == false {
t.Errorf("found incorrectly set to false")
}
if retUser.Uid != "testing" {
t.Errorf("user %s not found in group", username)
}
}
func TestGetLDAPUserObjectFromGroupUserNotFound(t *testing.T) {
username := "unknown"
retUser, found := GetLDAPUserObjectFromGroup(username, group1)
if found == true {
t.Errorf("found incorrectly set to false")
}
if retUser.Uid != "" {
t.Errorf("user %s incorrectly found in group", username)
}
}