2020-11-27 09:59:22 +00:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PasswordComplexityScenario struct {
|
2021-11-05 13:14:42 +00:00
|
|
|
*RodSuite
|
2020-11-27 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPasswordComplexityScenario() *PasswordComplexityScenario {
|
2023-01-25 04:11:05 +00:00
|
|
|
return &PasswordComplexityScenario{RodSuite: NewRodSuite("")}
|
2020-11-27 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) SetupSuite() {
|
2021-11-05 13:14:42 +00:00
|
|
|
browser, err := StartRod()
|
2020-11-27 09:59:22 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
s.RodSession = browser
|
2020-11-27 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) TearDownSuite() {
|
2021-11-05 13:14:42 +00:00
|
|
|
err := s.RodSession.Stop()
|
2020-11-27 09:59:22 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) SetupTest() {
|
2021-11-05 13:14:42 +00:00
|
|
|
s.Page = s.doCreateTab(s.T(), HomeBaseURL)
|
|
|
|
s.verifyIsHome(s.T(), s.Page)
|
|
|
|
}
|
2020-11-27 09:59:22 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (s *PasswordComplexityScenario) TearDownTest() {
|
|
|
|
s.collectCoverage(s.Page)
|
|
|
|
s.MustClose()
|
2020-11-27 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PasswordComplexityScenario) TestShouldRejectPasswordReset() {
|
2021-11-05 13:14:42 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
defer func() {
|
|
|
|
cancel()
|
|
|
|
s.collectScreenshot(ctx.Err(), s.Page)
|
|
|
|
}()
|
2020-11-27 09:59:22 +00:00
|
|
|
|
2023-01-12 10:57:44 +00:00
|
|
|
s.doVisit(s.T(), s.Context(ctx), GetLoginBaseURL(BaseDomain))
|
2021-11-05 13:14:42 +00:00
|
|
|
s.verifyIsFirstFactorPage(s.T(), s.Context(ctx))
|
2020-11-27 09:59:22 +00:00
|
|
|
|
2022-01-31 05:25:15 +00:00
|
|
|
// Attempt to reset the password to a.
|
2021-11-05 13:14:42 +00: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 09:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestRunPasswordComplexityScenario(t *testing.T) {
|
2021-03-14 07:08:26 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping suite test in short mode")
|
|
|
|
}
|
|
|
|
|
2020-11-27 09:59:22 +00:00
|
|
|
suite.Run(t, NewPasswordComplexityScenario())
|
|
|
|
}
|