Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonodonnell committed Mar 27, 2024
1 parent d1fc2bd commit ee34595
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ldap/client_exported_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,49 @@ func TestClient_Authenticate(t *testing.T) {
},
wantUserDN: "cn=alice,ou=people,dc=example,dc=org",
},
{
name: "success-with-user-attributes-lower-case-keys",
username: "alice",
password: "password",
clientConfig: &ldap.ClientConfig{
URLs: []string{fmt.Sprintf("ldaps://127.0.0.1:%d", td.Port())},
Certificates: []string{td.Cert()},
DiscoverDN: true,
UserDN: testdirectory.DefaultUserDN,
GroupDN: testdirectory.DefaultGroupDN,
ExcludedUserAttributes: []string{"password", "memberof"},
IncludeUserAttributes: true,
LowerUserAttributeKeys: true,
},
opts: []ldap.Option{ldap.WithUserAttributes()},
wantUserAttributes: map[string][]string{
"email": {"alice@example.com"},
"name": {"alice"},
"tokengroups": {"\x01\x00\x00\x00\x00\x00\x00\x01"},
},
wantUserDN: "cn=alice,ou=people,dc=example,dc=org",
},
{
name: "success-with-user-attributes-lower-case-keys-opt",
username: "alice",
password: "password",
clientConfig: &ldap.ClientConfig{
URLs: []string{fmt.Sprintf("ldaps://127.0.0.1:%d", td.Port())},
Certificates: []string{td.Cert()},
DiscoverDN: true,
UserDN: testdirectory.DefaultUserDN,
GroupDN: testdirectory.DefaultGroupDN,
ExcludedUserAttributes: []string{"password", "memberof"},
IncludeUserAttributes: true,
},
opts: []ldap.Option{ldap.WithUserAttributes(), ldap.WithLowerUserAttributeKeys()},
wantUserAttributes: map[string][]string{
"email": {"alice@example.com"},
"name": {"alice"},
"tokengroups": {"\x01\x00\x00\x00\x00\x00\x00\x01"},
},
wantUserDN: "cn=alice,ou=people,dc=example,dc=org",
},
{
name: "success-include-user-groups",
username: "alice",
Expand Down

0 comments on commit ee34595

Please sign in to comment.