authelia/internal/suites/action_reset_password.go
Amir Zarrinkafsh aa64d0c4e5
[FEATURE] Support MSAD password reset via unicodePwd attribute (#1460)
* Added `ActiveDirectory` suite for integration tests with Samba AD
* Updated documentation
* Minor styling refactor to suites
* Clean up LDAP user provisioning
* Fix Authelia home splash to reference correct link for webmail
* Add notification message for password complexity errors
* Add password complexity integration test
* Rename implementation default from rfc to custom
* add specific defaults for LDAP (activedirectory implementation)
* add docs to show the new defaults
* add docs explaining the importance of users filter
* add tests
* update instances of LDAP implementation names to use the new consts where applicable
* made the 'custom' case in the UpdatePassword method for the implementation switch the default case instead
* update config examples due to the new defaults
* apply changes from code review
* replace schema default name from MSAD to ActiveDirectory for consistency
* fix missing default for username_attribute
* replace test raising on empty username attribute with not raising on empty

Co-authored-by: James Elliott <james-d-elliott@users.noreply.github.com>
2020-11-27 20:59:22 +11:00

45 lines
2.2 KiB
Go

package suites
import (
"context"
"testing"
)
func (wds *WebDriverSession) doInitiatePasswordReset(ctx context.Context, t *testing.T, username string) {
wds.WaitElementLocatedByID(ctx, t, "reset-password-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
// Fill in username
wds.WaitElementLocatedByID(ctx, t, "username-textfield").SendKeys(username) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
// And click on the reset button
wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
}
func (wds *WebDriverSession) doCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) {
link := doGetLinkFromLastMail(t)
wds.doVisit(t, link)
wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
}
func (wds *WebDriverSession) doSuccessfullyCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) {
wds.doCompletePasswordReset(ctx, t, newPassword1, newPassword2)
wds.verifyIsFirstFactorPage(ctx, t)
}
func (wds *WebDriverSession) doUnsuccessfulPasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) {
wds.doCompletePasswordReset(ctx, t, newPassword1, newPassword2)
}
func (wds *WebDriverSession) doResetPassword(ctx context.Context, t *testing.T, username, newPassword1, newPassword2 string, unsuccessful bool) {
wds.doInitiatePasswordReset(ctx, t, username)
// then wait for the "email sent notification"
wds.verifyMailNotificationDisplayed(ctx, t)
if unsuccessful {
wds.doUnsuccessfulPasswordReset(ctx, t, newPassword1, newPassword2)
} else {
wds.doSuccessfullyCompletePasswordReset(ctx, t, newPassword1, newPassword2)
}
}