2020-11-27 16:59:22 +07:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordComplexityScenario struct {
|
2021-11-05 20:14:42 +07:00
|
|
|
*RodSuite
|
2020-11-27 16:59:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityScenario() *PasswordComplexityScenario {
|
2021-11-05 20:14:42 +07:00
|
|
|
return &PasswordComplexityScenario{RodSuite: new(RodSuite)}
|
2020-11-27 16:59:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) SetupSuite() {
|
2021-11-05 20:14:42 +07:00
|
|
|
browser, err := StartRod()
|
2020-11-27 16:59:22 +07:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
s.RodSession = browser
|
2020-11-27 16:59:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) TearDownSuite() {
|
2021-11-05 20:14:42 +07:00
|
|
|
err := s.RodSession.Stop()
|
2020-11-27 16:59:22 +07:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) SetupTest() {
|
2021-11-05 20:14:42 +07:00
|
|
|
s.Page = s.doCreateTab(s.T(), HomeBaseURL)
|
|
|
|
s.verifyIsHome(s.T(), s.Page)
|
|
|
|
}
|
2020-11-27 16:59:22 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
func (s *PasswordComplexityScenario) TearDownTest() {
|
|
|
|
s.collectCoverage(s.Page)
|
|
|
|
s.MustClose()
|
2020-11-27 16:59:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) TestShouldRejectPasswordReset() {
|
2021-11-05 20:14:42 +07:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
defer func() {
|
|
|
|
cancel()
|
|
|
|
s.collectScreenshot(ctx.Err(), s.Page)
|
|
|
|
}()
|
2020-11-27 16:59:22 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
s.doVisit(s.T(), s.Context(ctx), GetLoginBaseURL())
|
|
|
|
s.verifyIsFirstFactorPage(s.T(), s.Context(ctx))
|
2020-11-27 16:59:22 +07:00
|
|
|
|
2022-01-31 12:25:15 +07:00
|
|
|
// Attempt to reset the password to a.
|
2021-11-05 20:14:42 +07:00
|
|
|
s.doResetPassword(s.T(), s.Context(ctx), "john", "a", "a", true)
|
|
|
|
s.verifyNotificationDisplayed(s.T(), s.Context(ctx), "Your supplied password does not meet the password policy requirements.")
|
2020-11-27 16:59:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestRunPasswordComplexityScenario(t *testing.T) {
|
2021-03-14 14:08:26 +07:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping suite test in short mode")
|
|
|
|
}
|
|
|
|
|
2020-11-27 16:59:22 +07:00
|
|
|
suite.Run(t, NewPasswordComplexityScenario())
|
|
|
|
}
|