diff options
Diffstat (limited to 'internal/authentication/ldap_user_provider_test.go')
| -rw-r--r-- | internal/authentication/ldap_user_provider_test.go | 36 | 
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)  }  | 
