summaryrefslogtreecommitdiff
path: root/internal/authentication/ldap_user_provider_test.go
diff options
context:
space:
mode:
authorArsenović Arsen <arsen@aarsen.me>2021-07-06 09:13:17 +0000
committerGitHub <noreply@github.com>2021-07-06 19:13:17 +1000
commit8ee059748638c6cb65a2de99e5e2a26b02484497 (patch)
tree1ac6e72455a038bf4395e455b02c72c7cf17e2b2 /internal/authentication/ldap_user_provider_test.go
parent565515646a459e3cbef4b45bf43accdca105d15a (diff)
feat(authentication): use the passwordmodify exop for pwd resets with ldap (#2124)
Implement the LDAP password modify extended operation for LDAP providers that advertise they support it.
Diffstat (limited to 'internal/authentication/ldap_user_provider_test.go')
-rw-r--r--internal/authentication/ldap_user_provider_test.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/internal/authentication/ldap_user_provider_test.go b/internal/authentication/ldap_user_provider_test.go
index 8602bd8b1..82d6b1a84 100644
--- a/internal/authentication/ldap_user_provider_test.go
+++ b/internal/authentication/ldap_user_provider_test.go
@@ -649,8 +649,11 @@ func TestShouldUpdateUserPassword(t *testing.T) {
nil,
mockFactory)
- modifyRequest := ldap.NewModifyRequest("uid=test,dc=example,dc=com", nil)
- modifyRequest.Replace("userPassword", []string{"password"})
+ pwdModifyRequest := ldap.NewPasswordModifyRequest(
+ "uid=test,dc=example,dc=com",
+ "",
+ "password",
+ )
gomock.InOrder(
mockFactory.EXPECT().
@@ -659,6 +662,29 @@ func TestShouldUpdateUserPassword(t *testing.T) {
mockConn.EXPECT().
Bind(gomock.Eq("cn=admin,dc=example,dc=com"), gomock.Eq("password")).
Return(nil),
+
+ mockConn.EXPECT().
+ Search(NewExtendedSearchRequestMatcher("(objectClass=*)", "", ldap.ScopeBaseObject, ldap.NeverDerefAliases, false, []string{ldapSupportedExtensionAttribute})).
+ Return(&ldap.SearchResult{
+ Entries: []*ldap.Entry{
+ {
+ DN: "",
+ Attributes: []*ldap.EntryAttribute{
+ {
+ Name: ldapSupportedExtensionAttribute,
+ Values: []string{ldapOIDPasswdModifyExtension},
+ },
+ },
+ },
+ },
+ }, nil),
+
+ mockFactory.EXPECT().
+ DialURL(gomock.Eq("ldap://127.0.0.1:389"), gomock.Any()).
+ Return(mockConn, nil),
+ mockConn.EXPECT().
+ Bind(gomock.Eq("cn=admin,dc=example,dc=com"), gomock.Eq("password")).
+ Return(nil),
mockConn.EXPECT().
Search(gomock.Any()).
Return(&ldap.SearchResult{
@@ -683,14 +709,16 @@ func TestShouldUpdateUserPassword(t *testing.T) {
},
}, nil),
mockConn.EXPECT().
- Modify(modifyRequest).
+ PasswordModify(pwdModifyRequest).
Return(nil),
mockConn.EXPECT().
Close(),
)
- err := ldapClient.UpdatePassword("john", "password")
+ err := ldapClient.checkServer()
+ require.NoError(t, err)
+ err = ldapClient.UpdatePassword("john", "password")
require.NoError(t, err)
}