mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
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
This commit is contained in:
parent
f73738830e
commit
cac8919f97
|
@ -31,7 +31,7 @@ func (rs *RodSession) doEnterOTP(t *testing.T, page *rod.Page, code string) {
|
|||
inputs := rs.WaitElementsLocatedByID(t, page, "otp-input input")
|
||||
|
||||
for i := 0; i < len(code); i++ {
|
||||
_ = inputs[i].MustPress(rune(code[i]))
|
||||
inputs[i].MustInput(string(code[i]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ type OneFactorSuite struct {
|
|||
*RodSuite
|
||||
}
|
||||
|
||||
func NewOneFactorScenario() *OneFactorSuite {
|
||||
func New1FAScenario() *OneFactorSuite {
|
||||
return &OneFactorSuite{
|
||||
RodSuite: new(RodSuite),
|
||||
}
|
||||
|
@ -90,5 +90,5 @@ func TestRunOneFactor(t *testing.T) {
|
|||
t.Skip("skipping suite test in short mode")
|
||||
}
|
||||
|
||||
suite.Run(t, NewOneFactorScenario())
|
||||
suite.Run(t, New1FAScenario())
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type TwoFactorSuite struct {
|
|||
*RodSuite
|
||||
}
|
||||
|
||||
func NewTwoFactorScenario() *TwoFactorSuite {
|
||||
func New2FAScenario() *TwoFactorSuite {
|
||||
return &TwoFactorSuite{
|
||||
RodSuite: new(RodSuite),
|
||||
}
|
||||
|
@ -97,5 +97,5 @@ func TestRunTwoFactor(t *testing.T) {
|
|||
t.Skip("skipping suite test in short mode")
|
||||
}
|
||||
|
||||
suite.Run(t, NewTwoFactorScenario())
|
||||
suite.Run(t, New2FAScenario())
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewActiveDirectorySuite() *ActiveDirectorySuite {
|
|||
return &ActiveDirectorySuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *ActiveDirectorySuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *ActiveDirectorySuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *ActiveDirectorySuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *ActiveDirectorySuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *ActiveDirectorySuite) TestResetPassword() {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewDockerSuite() *DockerSuite {
|
|||
return &DockerSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *DockerSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *DockerSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func TestDockerSuite(t *testing.T) {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewHAProxySuite() *HAProxySuite {
|
|||
return &HAProxySuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *HAProxySuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *HAProxySuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *HAProxySuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *HAProxySuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *HAProxySuite) TestCustomHeaders() {
|
||||
|
|
|
@ -288,12 +288,12 @@ func (s *HighAvailabilitySuite) TestBasicAuth() {
|
|||
s.Assert().Equal(DoGetWithAuth(s.T(), "dontexist", "password"), 302)
|
||||
}
|
||||
|
||||
func (s *HighAvailabilitySuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *HighAvailabilitySuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *HighAvailabilitySuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *HighAvailabilitySuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *HighAvailabilitySuite) TestRegulationScenario() {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewKubernetesSuite() *KubernetesSuite {
|
|||
return &KubernetesSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *KubernetesSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *KubernetesSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *KubernetesSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *KubernetesSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *KubernetesSuite) TestRedirectionURLScenario() {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewLDAPSuite() *LDAPSuite {
|
|||
return &LDAPSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *LDAPSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *LDAPSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *LDAPSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *LDAPSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *LDAPSuite) TestResetPassword() {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewMariaDBSuite() *MariaDBSuite {
|
|||
return &MariaDBSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *MariaDBSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *MariaDBSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *MariaDBSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *MariaDBSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func TestMariaDBSuite(t *testing.T) {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewMySQLSuite() *MySQLSuite {
|
|||
return &MySQLSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *MySQLSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *MySQLSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *MySQLSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *MySQLSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func TestMySQLSuite(t *testing.T) {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewPathPrefixSuite() *PathPrefixSuite {
|
|||
return &PathPrefixSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *PathPrefixSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *PathPrefixSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *PathPrefixSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *PathPrefixSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *PathPrefixSuite) TestCustomHeaders() {
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewPostgresSuite() *PostgresSuite {
|
|||
return &PostgresSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *PostgresSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *PostgresSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *PostgresSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *PostgresSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func TestPostgresSuite(t *testing.T) {
|
||||
|
|
|
@ -267,12 +267,12 @@ func (s *StandaloneSuite) TestStandaloneWebDriverScenario() {
|
|||
suite.Run(s.T(), NewStandaloneWebDriverSuite())
|
||||
}
|
||||
|
||||
func (s *StandaloneSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *StandaloneSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *StandaloneSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *StandaloneSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *StandaloneSuite) TestBypassPolicyScenario() {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package suites
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
@ -14,12 +17,12 @@ func NewTraefik2Suite() *Traefik2Suite {
|
|||
return &Traefik2Suite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *Traefik2Suite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *Traefik2Suite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *Traefik2Suite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *Traefik2Suite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *Traefik2Suite) TestCustomHeaders() {
|
||||
|
@ -30,6 +33,37 @@ func (s *Traefik2Suite) TestResetPasswordScenario() {
|
|||
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) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping suite test in short mode")
|
||||
|
|
|
@ -14,12 +14,12 @@ func NewTraefikSuite() *TraefikSuite {
|
|||
return &TraefikSuite{RodSuite: new(RodSuite)}
|
||||
}
|
||||
|
||||
func (s *TraefikSuite) TestOneFactorScenario() {
|
||||
suite.Run(s.T(), NewOneFactorScenario())
|
||||
func (s *TraefikSuite) Test1FAScenario() {
|
||||
suite.Run(s.T(), New1FAScenario())
|
||||
}
|
||||
|
||||
func (s *TraefikSuite) TestTwoFactorScenario() {
|
||||
suite.Run(s.T(), NewTwoFactorScenario())
|
||||
func (s *TraefikSuite) Test2FAScenario() {
|
||||
suite.Run(s.T(), New2FAScenario())
|
||||
}
|
||||
|
||||
func (s *TraefikSuite) TestRedirectionURLScenario() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user