test: add redis restart test back to traefik2 suite (#3298)

* test: add redis restart test back to traefik2 suite

* refactor(suites): mustpress -> mustinput for totp

* refactor(suites): rename suites for test ordering
pull/3289/head^2
Amir Zarrinkafsh 2022-05-04 11:01:36 +10:00 committed by GitHub
parent f73738830e
commit cac8919f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 91 additions and 57 deletions

View File

@ -31,7 +31,7 @@ func (rs *RodSession) doEnterOTP(t *testing.T, page *rod.Page, code string) {
inputs := rs.WaitElementsLocatedByID(t, page, "otp-input input") inputs := rs.WaitElementsLocatedByID(t, page, "otp-input input")
for i := 0; i < len(code); i++ { for i := 0; i < len(code); i++ {
_ = inputs[i].MustPress(rune(code[i])) inputs[i].MustInput(string(code[i]))
} }
} }

View File

@ -14,7 +14,7 @@ type OneFactorSuite struct {
*RodSuite *RodSuite
} }
func NewOneFactorScenario() *OneFactorSuite { func New1FAScenario() *OneFactorSuite {
return &OneFactorSuite{ return &OneFactorSuite{
RodSuite: new(RodSuite), RodSuite: new(RodSuite),
} }
@ -90,5 +90,5 @@ func TestRunOneFactor(t *testing.T) {
t.Skip("skipping suite test in short mode") t.Skip("skipping suite test in short mode")
} }
suite.Run(t, NewOneFactorScenario()) suite.Run(t, New1FAScenario())
} }

View File

@ -14,7 +14,7 @@ type TwoFactorSuite struct {
*RodSuite *RodSuite
} }
func NewTwoFactorScenario() *TwoFactorSuite { func New2FAScenario() *TwoFactorSuite {
return &TwoFactorSuite{ return &TwoFactorSuite{
RodSuite: new(RodSuite), RodSuite: new(RodSuite),
} }
@ -97,5 +97,5 @@ func TestRunTwoFactor(t *testing.T) {
t.Skip("skipping suite test in short mode") t.Skip("skipping suite test in short mode")
} }
suite.Run(t, NewTwoFactorScenario()) suite.Run(t, New2FAScenario())
} }

View File

@ -14,12 +14,12 @@ func NewActiveDirectorySuite() *ActiveDirectorySuite {
return &ActiveDirectorySuite{RodSuite: new(RodSuite)} return &ActiveDirectorySuite{RodSuite: new(RodSuite)}
} }
func (s *ActiveDirectorySuite) TestOneFactorScenario() { func (s *ActiveDirectorySuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *ActiveDirectorySuite) TestTwoFactorScenario() { func (s *ActiveDirectorySuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *ActiveDirectorySuite) TestResetPassword() { func (s *ActiveDirectorySuite) TestResetPassword() {

View File

@ -14,12 +14,12 @@ func NewDockerSuite() *DockerSuite {
return &DockerSuite{RodSuite: new(RodSuite)} return &DockerSuite{RodSuite: new(RodSuite)}
} }
func (s *DockerSuite) TestOneFactorScenario() { func (s *DockerSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *DockerSuite) TestTwoFactorScenario() { func (s *DockerSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func TestDockerSuite(t *testing.T) { func TestDockerSuite(t *testing.T) {

View File

@ -14,12 +14,12 @@ func NewHAProxySuite() *HAProxySuite {
return &HAProxySuite{RodSuite: new(RodSuite)} return &HAProxySuite{RodSuite: new(RodSuite)}
} }
func (s *HAProxySuite) TestOneFactorScenario() { func (s *HAProxySuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *HAProxySuite) TestTwoFactorScenario() { func (s *HAProxySuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *HAProxySuite) TestCustomHeaders() { func (s *HAProxySuite) TestCustomHeaders() {

View File

@ -288,12 +288,12 @@ func (s *HighAvailabilitySuite) TestBasicAuth() {
s.Assert().Equal(DoGetWithAuth(s.T(), "dontexist", "password"), 302) s.Assert().Equal(DoGetWithAuth(s.T(), "dontexist", "password"), 302)
} }
func (s *HighAvailabilitySuite) TestOneFactorScenario() { func (s *HighAvailabilitySuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *HighAvailabilitySuite) TestTwoFactorScenario() { func (s *HighAvailabilitySuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *HighAvailabilitySuite) TestRegulationScenario() { func (s *HighAvailabilitySuite) TestRegulationScenario() {

View File

@ -14,12 +14,12 @@ func NewKubernetesSuite() *KubernetesSuite {
return &KubernetesSuite{RodSuite: new(RodSuite)} return &KubernetesSuite{RodSuite: new(RodSuite)}
} }
func (s *KubernetesSuite) TestOneFactorScenario() { func (s *KubernetesSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *KubernetesSuite) TestTwoFactorScenario() { func (s *KubernetesSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *KubernetesSuite) TestRedirectionURLScenario() { func (s *KubernetesSuite) TestRedirectionURLScenario() {

View File

@ -14,12 +14,12 @@ func NewLDAPSuite() *LDAPSuite {
return &LDAPSuite{RodSuite: new(RodSuite)} return &LDAPSuite{RodSuite: new(RodSuite)}
} }
func (s *LDAPSuite) TestOneFactorScenario() { func (s *LDAPSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *LDAPSuite) TestTwoFactorScenario() { func (s *LDAPSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *LDAPSuite) TestResetPassword() { func (s *LDAPSuite) TestResetPassword() {

View File

@ -14,12 +14,12 @@ func NewMariaDBSuite() *MariaDBSuite {
return &MariaDBSuite{RodSuite: new(RodSuite)} return &MariaDBSuite{RodSuite: new(RodSuite)}
} }
func (s *MariaDBSuite) TestOneFactorScenario() { func (s *MariaDBSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *MariaDBSuite) TestTwoFactorScenario() { func (s *MariaDBSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func TestMariaDBSuite(t *testing.T) { func TestMariaDBSuite(t *testing.T) {

View File

@ -14,12 +14,12 @@ func NewMySQLSuite() *MySQLSuite {
return &MySQLSuite{RodSuite: new(RodSuite)} return &MySQLSuite{RodSuite: new(RodSuite)}
} }
func (s *MySQLSuite) TestOneFactorScenario() { func (s *MySQLSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *MySQLSuite) TestTwoFactorScenario() { func (s *MySQLSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func TestMySQLSuite(t *testing.T) { func TestMySQLSuite(t *testing.T) {

View File

@ -14,12 +14,12 @@ func NewPathPrefixSuite() *PathPrefixSuite {
return &PathPrefixSuite{RodSuite: new(RodSuite)} return &PathPrefixSuite{RodSuite: new(RodSuite)}
} }
func (s *PathPrefixSuite) TestOneFactorScenario() { func (s *PathPrefixSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *PathPrefixSuite) TestTwoFactorScenario() { func (s *PathPrefixSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *PathPrefixSuite) TestCustomHeaders() { func (s *PathPrefixSuite) TestCustomHeaders() {

View File

@ -14,12 +14,12 @@ func NewPostgresSuite() *PostgresSuite {
return &PostgresSuite{RodSuite: new(RodSuite)} return &PostgresSuite{RodSuite: new(RodSuite)}
} }
func (s *PostgresSuite) TestOneFactorScenario() { func (s *PostgresSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *PostgresSuite) TestTwoFactorScenario() { func (s *PostgresSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func TestPostgresSuite(t *testing.T) { func TestPostgresSuite(t *testing.T) {

View File

@ -267,12 +267,12 @@ func (s *StandaloneSuite) TestStandaloneWebDriverScenario() {
suite.Run(s.T(), NewStandaloneWebDriverSuite()) suite.Run(s.T(), NewStandaloneWebDriverSuite())
} }
func (s *StandaloneSuite) TestOneFactorScenario() { func (s *StandaloneSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *StandaloneSuite) TestTwoFactorScenario() { func (s *StandaloneSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *StandaloneSuite) TestBypassPolicyScenario() { func (s *StandaloneSuite) TestBypassPolicyScenario() {

View File

@ -1,7 +1,10 @@
package suites package suites
import ( import (
"context"
"fmt"
"testing" "testing"
"time"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
@ -14,12 +17,12 @@ func NewTraefik2Suite() *Traefik2Suite {
return &Traefik2Suite{RodSuite: new(RodSuite)} return &Traefik2Suite{RodSuite: new(RodSuite)}
} }
func (s *Traefik2Suite) TestOneFactorScenario() { func (s *Traefik2Suite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *Traefik2Suite) TestTwoFactorScenario() { func (s *Traefik2Suite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *Traefik2Suite) TestCustomHeaders() { func (s *Traefik2Suite) TestCustomHeaders() {
@ -30,6 +33,37 @@ func (s *Traefik2Suite) TestResetPasswordScenario() {
suite.Run(s.T(), NewResetPasswordScenario()) suite.Run(s.T(), NewResetPasswordScenario())
} }
func (s *Traefik2Suite) TestShouldKeepSessionAfterRedisRestart() {
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
defer func() {
cancel()
s.collectCoverage(s.Page)
s.collectScreenshot(ctx.Err(), s.Page)
s.MustClose()
err := s.RodSession.Stop()
s.Require().NoError(err)
}()
browser, err := StartRod()
s.Require().NoError(err)
s.RodSession = browser
s.Page = s.doCreateTab(s.T(), HomeBaseURL)
s.verifyIsHome(s.T(), s.Page)
secret := s.doRegisterThenLogout(s.T(), s.Context(ctx), "john", "password")
s.doLoginTwoFactor(s.T(), s.Context(ctx), "john", "password", false, secret, "")
s.doVisit(s.T(), s.Context(ctx), fmt.Sprintf("%s/secret.html", SecureBaseURL))
s.verifySecretAuthorized(s.T(), s.Context(ctx))
err = traefik2DockerEnvironment.Restart("redis")
s.Require().NoError(err)
s.doVisit(s.T(), s.Context(ctx), fmt.Sprintf("%s/secret.html", SecureBaseURL))
s.verifySecretAuthorized(s.T(), s.Context(ctx))
}
func TestTraefik2Suite(t *testing.T) { func TestTraefik2Suite(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping suite test in short mode") t.Skip("skipping suite test in short mode")

View File

@ -14,12 +14,12 @@ func NewTraefikSuite() *TraefikSuite {
return &TraefikSuite{RodSuite: new(RodSuite)} return &TraefikSuite{RodSuite: new(RodSuite)}
} }
func (s *TraefikSuite) TestOneFactorScenario() { func (s *TraefikSuite) Test1FAScenario() {
suite.Run(s.T(), NewOneFactorScenario()) suite.Run(s.T(), New1FAScenario())
} }
func (s *TraefikSuite) TestTwoFactorScenario() { func (s *TraefikSuite) Test2FAScenario() {
suite.Run(s.T(), NewTwoFactorScenario()) suite.Run(s.T(), New2FAScenario())
} }
func (s *TraefikSuite) TestRedirectionURLScenario() { func (s *TraefikSuite) TestRedirectionURLScenario() {