-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldap_test.go
51 lines (44 loc) · 1.08 KB
/
ldap_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
48
49
50
51
package gw
import (
"testing"
)
func setupLDAP() LDAPConfiguration {
return LDAP{
Host: "ldapserver.example.com",
Port: 389,
BindUsername: "cn=binduser,dc=example,dc=com",
BindPassword: "abcdefgh",
BaseDN: "dc=example,dc=com",
UserDN: "ou=users,dc=example,dc=com",
GroupDN: "ou=grps,dc=example,dc=com",
}
}
func TestUsernameToDN(t *testing.T) {
l := setupLDAP()
u := l.UsernameToDN("tester")
if u != "uid=tester,ou=users,dc=example,dc=com" {
t.Errorf("Incorrect DN returned: %s", u)
}
}
func TestGroupnameToDN(t *testing.T) {
l := setupLDAP()
g := l.GroupnameToDN("testers")
if g != "cn=testers,ou=grps,dc=example,dc=com" {
t.Errorf("Incorrect DN returned: %s", g)
}
}
func TestFormatServer(t *testing.T) {
l := setupLDAP()
s := l.FormatServer()
if s != "ldapserver.example.com:389" {
t.Error("Not formatting server properly: %s", s)
}
}
// Bail, not a great way to test this at the moment.
func TestAuth(t *testing.T) {
t.Skip()
}
// Bail, not a great way to test this at the moment.
func TestAuthenticate(t *testing.T) {
t.Skip()
}