mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
0a970aef8a
This moves the OpenID Connect storage from memory into the SQL storage, making it persistent and allowing it to be used with clustered deployments like the rest of Authelia.
61 lines
2.1 KiB
Go
61 lines
2.1 KiB
Go
package suites
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/go-rod/rod"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func (rs *RodSession) doInitiatePasswordReset(t *testing.T, page *rod.Page, username string) {
|
|
err := rs.WaitElementLocatedByID(t, page, "reset-password-button").Click("left")
|
|
require.NoError(t, err)
|
|
// Fill in username.
|
|
err = rs.WaitElementLocatedByID(t, page, "username-textfield").Input(username)
|
|
require.NoError(t, err)
|
|
// And click on the reset button.
|
|
err = rs.WaitElementLocatedByID(t, page, "reset-button").Click("left")
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func (rs *RodSession) doCompletePasswordReset(t *testing.T, page *rod.Page, newPassword1, newPassword2 string) {
|
|
link := doGetLinkFromLastMail(t)
|
|
rs.doVisit(t, page, link)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
err := rs.WaitElementLocatedByID(t, page, "password1-textfield").Input(newPassword1)
|
|
require.NoError(t, err)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
err = rs.WaitElementLocatedByID(t, page, "password2-textfield").Input(newPassword2)
|
|
require.NoError(t, err)
|
|
|
|
err = rs.WaitElementLocatedByID(t, page, "reset-button").Click("left")
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func (rs *RodSession) doSuccessfullyCompletePasswordReset(t *testing.T, page *rod.Page, newPassword1, newPassword2 string) {
|
|
rs.doCompletePasswordReset(t, page, newPassword1, newPassword2)
|
|
rs.verifyIsFirstFactorPage(t, page)
|
|
}
|
|
|
|
func (rs *RodSession) doUnsuccessfulPasswordReset(t *testing.T, page *rod.Page, newPassword1, newPassword2 string) {
|
|
rs.doCompletePasswordReset(t, page, newPassword1, newPassword2)
|
|
rs.verifyNotificationDisplayed(t, page, "Your supplied password does not meet the password policy requirements.")
|
|
}
|
|
|
|
func (rs *RodSession) doResetPassword(t *testing.T, page *rod.Page, username, newPassword1, newPassword2 string, unsuccessful bool) {
|
|
rs.doInitiatePasswordReset(t, page, username)
|
|
// then wait for the "email sent notification".
|
|
rs.verifyMailNotificationDisplayed(t, page)
|
|
|
|
if unsuccessful {
|
|
rs.doUnsuccessfulPasswordReset(t, page, newPassword1, newPassword2)
|
|
} else {
|
|
rs.doSuccessfullyCompletePasswordReset(t, page, newPassword1, newPassword2)
|
|
}
|
|
}
|