diff --git a/internal/suites/action_totp.go b/internal/suites/action_totp.go index d71b7712..c4cf63a3 100644 --- a/internal/suites/action_totp.go +++ b/internal/suites/action_totp.go @@ -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])) } } diff --git a/internal/suites/scenario_one_factor_test.go b/internal/suites/scenario_one_factor_test.go index 312d6657..84cbee9c 100644 --- a/internal/suites/scenario_one_factor_test.go +++ b/internal/suites/scenario_one_factor_test.go @@ -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()) } diff --git a/internal/suites/scenario_two_factor_test.go b/internal/suites/scenario_two_factor_test.go index 81b0f8bf..7672aab7 100644 --- a/internal/suites/scenario_two_factor_test.go +++ b/internal/suites/scenario_two_factor_test.go @@ -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()) } diff --git a/internal/suites/suite_activedirectory_test.go b/internal/suites/suite_activedirectory_test.go index 48e7f9b0..9e7bce98 100644 --- a/internal/suites/suite_activedirectory_test.go +++ b/internal/suites/suite_activedirectory_test.go @@ -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() { diff --git a/internal/suites/suite_docker_test.go b/internal/suites/suite_docker_test.go index 8b6f23b7..68df0c6c 100644 --- a/internal/suites/suite_docker_test.go +++ b/internal/suites/suite_docker_test.go @@ -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) { diff --git a/internal/suites/suite_haproxy_test.go b/internal/suites/suite_haproxy_test.go index 1c66242b..96ef115f 100644 --- a/internal/suites/suite_haproxy_test.go +++ b/internal/suites/suite_haproxy_test.go @@ -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() { diff --git a/internal/suites/suite_high_availability_test.go b/internal/suites/suite_high_availability_test.go index 2153aaa9..714d7ab2 100644 --- a/internal/suites/suite_high_availability_test.go +++ b/internal/suites/suite_high_availability_test.go @@ -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() { diff --git a/internal/suites/suite_kubernetes_test.go b/internal/suites/suite_kubernetes_test.go index a40889dd..fe382ee1 100644 --- a/internal/suites/suite_kubernetes_test.go +++ b/internal/suites/suite_kubernetes_test.go @@ -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() { diff --git a/internal/suites/suite_ldap_test.go b/internal/suites/suite_ldap_test.go index 96334f8a..c7562780 100644 --- a/internal/suites/suite_ldap_test.go +++ b/internal/suites/suite_ldap_test.go @@ -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() { diff --git a/internal/suites/suite_mariadb_test.go b/internal/suites/suite_mariadb_test.go index 1c587cad..35b71f23 100644 --- a/internal/suites/suite_mariadb_test.go +++ b/internal/suites/suite_mariadb_test.go @@ -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) { diff --git a/internal/suites/suite_mysql_test.go b/internal/suites/suite_mysql_test.go index 1a634ad2..a2e90e01 100644 --- a/internal/suites/suite_mysql_test.go +++ b/internal/suites/suite_mysql_test.go @@ -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) { diff --git a/internal/suites/suite_pathprefix_test.go b/internal/suites/suite_pathprefix_test.go index 098897af..1f310b14 100644 --- a/internal/suites/suite_pathprefix_test.go +++ b/internal/suites/suite_pathprefix_test.go @@ -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() { diff --git a/internal/suites/suite_postgres_test.go b/internal/suites/suite_postgres_test.go index 616702f5..fb737f8c 100644 --- a/internal/suites/suite_postgres_test.go +++ b/internal/suites/suite_postgres_test.go @@ -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) { diff --git a/internal/suites/suite_standalone_test.go b/internal/suites/suite_standalone_test.go index 9e50dc9a..acce2985 100644 --- a/internal/suites/suite_standalone_test.go +++ b/internal/suites/suite_standalone_test.go @@ -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() { diff --git a/internal/suites/suite_traefik2_test.go b/internal/suites/suite_traefik2_test.go index c9d08c5e..9a057134 100644 --- a/internal/suites/suite_traefik2_test.go +++ b/internal/suites/suite_traefik2_test.go @@ -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") diff --git a/internal/suites/suite_traefik_test.go b/internal/suites/suite_traefik_test.go index 3c1fbc7a..19518467 100644 --- a/internal/suites/suite_traefik_test.go +++ b/internal/suites/suite_traefik_test.go @@ -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() {