Be able to run scenarii in isolation for each suite.

pull/477/head
Clement Michaud 2019-12-05 22:35:03 +01:00 committed by Clément Michaud
parent 2b544346f3
commit 336276be98
11 changed files with 172 additions and 57 deletions

View File

@ -10,15 +10,15 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
type BypassAllSuite struct { type BypassAllWebDriverSuite struct {
*SeleniumSuite *SeleniumSuite
} }
func NewBypassAllSuite() *BypassAllSuite { func NewBypassAllWebDriverSuite() *BypassAllWebDriverSuite {
return &BypassAllSuite{SeleniumSuite: new(SeleniumSuite)} return &BypassAllWebDriverSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func (s *BypassAllSuite) SetupSuite() { func (s *BypassAllWebDriverSuite) SetupSuite() {
wds, err := StartWebDriver() wds, err := StartWebDriver()
if err != nil { if err != nil {
@ -28,7 +28,7 @@ func (s *BypassAllSuite) SetupSuite() {
s.WebDriverSession = wds s.WebDriverSession = wds
} }
func (s *BypassAllSuite) TearDownSuite() { func (s *BypassAllWebDriverSuite) TearDownSuite() {
err := s.WebDriverSession.Stop() err := s.WebDriverSession.Stop()
if err != nil { if err != nil {
@ -36,7 +36,7 @@ func (s *BypassAllSuite) TearDownSuite() {
} }
} }
func (s *BypassAllSuite) TestShouldAccessPublicResource() { func (s *BypassAllWebDriverSuite) TestShouldAccessPublicResource() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
@ -47,7 +47,22 @@ func (s *BypassAllSuite) TestShouldAccessPublicResource() {
s.verifySecretAuthorized(ctx, s.T()) s.verifySecretAuthorized(ctx, s.T())
} }
type BypassAllSuite struct {
suite.Suite
}
func NewBypassAllSuite() *BypassAllSuite {
return &BypassAllSuite{}
}
func (s *BypassAllSuite) TestBypassAllWebDriverSuite() {
suite.Run(s.T(), NewBypassAllWebDriverSuite())
}
func (s *BypassAllSuite) TestCustomHeadersScenario() {
suite.Run(s.T(), NewCustomHeadersScenario())
}
func TestBypassAllSuite(t *testing.T) { func TestBypassAllSuite(t *testing.T) {
suite.Run(t, NewBypassAllSuite()) suite.Run(t, NewBypassAllSuite())
suite.Run(t, NewCustomHeadersScenario())
} }

View File

@ -14,7 +14,14 @@ func NewDockerSuite() *DockerSuite {
return &DockerSuite{SeleniumSuite: new(SeleniumSuite)} return &DockerSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestDockerSuite(t *testing.T) { func (s *DockerSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *DockerSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestDockerSuite(t *testing.T) {
suite.Run(t, NewDockerSuite())
} }

View File

@ -9,15 +9,15 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
type DuoPushSuite struct { type DuoPushWebDriverSuite struct {
*SeleniumSuite *SeleniumSuite
} }
func NewDuoPushSuite() *DuoPushSuite { func NewDuoPushWebDriverSuite() *DuoPushWebDriverSuite {
return &DuoPushSuite{SeleniumSuite: new(SeleniumSuite)} return &DuoPushWebDriverSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func (s *DuoPushSuite) SetupSuite() { func (s *DuoPushWebDriverSuite) SetupSuite() {
wds, err := StartWebDriver() wds, err := StartWebDriver()
if err != nil { if err != nil {
@ -27,7 +27,7 @@ func (s *DuoPushSuite) SetupSuite() {
s.WebDriverSession = wds s.WebDriverSession = wds
} }
func (s *DuoPushSuite) TearDownSuite() { func (s *DuoPushWebDriverSuite) TearDownSuite() {
err := s.WebDriverSession.Stop() err := s.WebDriverSession.Stop()
if err != nil { if err != nil {
@ -35,14 +35,14 @@ func (s *DuoPushSuite) TearDownSuite() {
} }
} }
func (s *DuoPushSuite) SetupTest() { func (s *DuoPushWebDriverSuite) SetupTest() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
s.doLogout(ctx, s.T()) s.doLogout(ctx, s.T())
} }
func (s *DuoPushSuite) TearDownTest() { func (s *DuoPushWebDriverSuite) TearDownTest() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
@ -50,7 +50,7 @@ func (s *DuoPushSuite) TearDownTest() {
s.WaitElementLocatedByID(ctx, s.T(), "one-time-password-method") s.WaitElementLocatedByID(ctx, s.T(), "one-time-password-method")
} }
func (s *DuoPushSuite) TestShouldSucceedAuthentication() { func (s *DuoPushWebDriverSuite) TestShouldSucceedAuthentication() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() defer cancel()
@ -61,7 +61,7 @@ func (s *DuoPushSuite) TestShouldSucceedAuthentication() {
s.WaitElementLocatedByClassName(ctx, s.T(), "success-icon") s.WaitElementLocatedByClassName(ctx, s.T(), "success-icon")
} }
func (s *DuoPushSuite) TestShouldFailAuthentication() { func (s *DuoPushWebDriverSuite) TestShouldFailAuthentication() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() defer cancel()
@ -72,11 +72,29 @@ func (s *DuoPushSuite) TestShouldFailAuthentication() {
s.WaitElementLocatedByClassName(ctx, s.T(), "failure-icon") s.WaitElementLocatedByClassName(ctx, s.T(), "failure-icon")
} }
func TestDuoPushSuite(t *testing.T) { type DuoPushSuite struct {
suite.Run(t, NewDuoPushSuite()) suite.Suite
suite.Run(t, NewAvailableMethodsScenario([]string{ }
func NewDuoPushSuite() *DuoPushSuite {
return &DuoPushSuite{}
}
func (s *DuoPushSuite) TestDuoPushWebDriverSuite() {
suite.Run(s.T(), NewDuoPushWebDriverSuite())
}
func (s *DuoPushSuite) TestAvailableMethodsScenario() {
suite.Run(s.T(), NewAvailableMethodsScenario([]string{
"ONE-TIME PASSWORD", "ONE-TIME PASSWORD",
"PUSH NOTIFICATION", "PUSH NOTIFICATION",
})) }))
suite.Run(t, NewUserPreferencesScenario()) }
func (s *DuoPushSuite) TestUserPreferencesScenario() {
suite.Run(s.T(), NewUserPreferencesScenario())
}
func TestDuoPushSuite(t *testing.T) {
suite.Run(t, NewDuoPushSuite())
} }

View File

@ -203,15 +203,32 @@ func (s *HighAvailabilitySuite) TestBasicAuth() {
s.Assert().Equal(DoGetWithAuth(s.T(), "john", "password"), 200) s.Assert().Equal(DoGetWithAuth(s.T(), "john", "password"), 200)
s.Assert().Equal(DoGetWithAuth(s.T(), "john", "bad-password"), 302) s.Assert().Equal(DoGetWithAuth(s.T(), "john", "bad-password"), 302)
s.Assert().Equal(DoGetWithAuth(s.T(), "dontexist", "password"), 302) s.Assert().Equal(DoGetWithAuth(s.T(), "dontexist", "password"), 302)
}
func (s *HighAvailabilitySuite) TestOneFactorScenario() {
suite.Run(s.T(), NewOneFactorScenario())
}
func (s *HighAvailabilitySuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func (s *HighAvailabilitySuite) TestRegulationScenario() {
suite.Run(s.T(), NewRegulationScenario())
}
func (s *HighAvailabilitySuite) TestCustomHeadersScenario() {
suite.Run(s.T(), NewCustomHeadersScenario())
}
func (s *HighAvailabilitySuite) TestRedirectionCheckScenario() {
suite.Run(s.T(), NewRedirectionCheckScenario())
}
func (s *HighAvailabilitySuite) TestHighAvailabilityWebDriverSuite() {
suite.Run(s.T(), NewHighAvailabilityWebDriverSuite())
} }
func TestHighAvailabilitySuite(t *testing.T) { func TestHighAvailabilitySuite(t *testing.T) {
suite.Run(t, NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario())
suite.Run(t, NewRegulationScenario())
suite.Run(t, NewCustomHeadersScenario())
suite.Run(t, NewRedirectionCheckScenario())
suite.Run(t, NewHighAvailabilityWebDriverSuite())
suite.Run(t, NewHighAvailabilitySuite()) suite.Run(t, NewHighAvailabilitySuite())
} }

View File

@ -14,7 +14,14 @@ func NewKubernetesSuite() *KubernetesSuite {
return &KubernetesSuite{SeleniumSuite: new(SeleniumSuite)} return &KubernetesSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestKubernetesSuite(t *testing.T) { func (s *KubernetesSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *KubernetesSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestKubernetesSuite(t *testing.T) {
suite.Run(t, NewKubernetesSuite())
} }

View File

@ -14,7 +14,14 @@ func NewLDAPSuite() *LDAPSuite {
return &LDAPSuite{SeleniumSuite: new(SeleniumSuite)} return &LDAPSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestLDAPSuite(t *testing.T) { func (s *LDAPSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *LDAPSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestLDAPSuite(t *testing.T) {
suite.Run(t, NewLDAPSuite())
} }

View File

@ -14,7 +14,14 @@ func NewMariadbSuite() *MariadbSuite {
return &MariadbSuite{SeleniumSuite: new(SeleniumSuite)} return &MariadbSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestMariadbSuite(t *testing.T) { func (s *MariadbSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *MariadbSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestMariadbSuite(t *testing.T) {
suite.Run(t, NewMariadbSuite())
} }

View File

@ -14,7 +14,14 @@ func NewPostgresSuite() *PostgresSuite {
return &PostgresSuite{SeleniumSuite: new(SeleniumSuite)} return &PostgresSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestPostgresSuite(t *testing.T) { func (s *PostgresSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *PostgresSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestPostgresSuite(t *testing.T) {
suite.Run(t, NewPostgresSuite())
} }

View File

@ -14,7 +14,14 @@ func NewShortTimeoutsSuite() *ShortTimeoutsSuite {
return &ShortTimeoutsSuite{SeleniumSuite: new(SeleniumSuite)} return &ShortTimeoutsSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestShortTimeoutsSuite(t *testing.T) { func (s *ShortTimeoutsSuite) TestInactivityScenario() {
suite.Run(t, NewInactivityScenario()) suite.Run(s.T(), NewInactivityScenario())
suite.Run(t, NewRegulationScenario()) }
func (s *ShortTimeoutsSuite) TestRegulationScenario() {
suite.Run(s.T(), NewRegulationScenario())
}
func TestShortTimeoutsSuite(t *testing.T) {
suite.Run(t, NewShortTimeoutsSuite())
} }

View File

@ -121,18 +121,34 @@ func (s *StandaloneSuite) TestShouldVerifyAPIVerifyRedirectFromXOriginalHostURI(
s.Assert().Equal(string(body), fmt.Sprintf("Found. Redirecting to %s?rd=https://secure.example.com:8080/", LoginBaseURL)) s.Assert().Equal(string(body), fmt.Sprintf("Found. Redirecting to %s?rd=https://secure.example.com:8080/", LoginBaseURL))
} }
func TestStandaloneWebDriverScenario(t *testing.T) { func (s *StandaloneSuite) TestStandaloneWebDriverScenario() {
suite.Run(t, NewStandaloneWebDriverSuite()) suite.Run(s.T(), NewStandaloneWebDriverSuite())
}
func (s *StandaloneSuite) TestOneFactorScenario() {
suite.Run(s.T(), NewOneFactorScenario())
}
func (s *StandaloneSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func (s *StandaloneSuite) TestBypassPolicyScenario() {
suite.Run(s.T(), NewBypassPolicyScenario())
}
func (s *StandaloneSuite) TestBackendProtectionScenario() {
suite.Run(s.T(), NewBackendProtectionScenario())
}
func (s *StandaloneSuite) TestResetPasswordScenario() {
suite.Run(s.T(), NewResetPasswordScenario())
}
func (s *StandaloneSuite) TestAvailableMethodsScenario() {
suite.Run(s.T(), NewAvailableMethodsScenario([]string{"ONE-TIME PASSWORD"}))
} }
func TestStandaloneSuite(t *testing.T) { func TestStandaloneSuite(t *testing.T) {
suite.Run(t, NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario())
suite.Run(t, NewBypassPolicyScenario())
suite.Run(t, NewBackendProtectionScenario())
suite.Run(t, NewResetPasswordScenario())
suite.Run(t, NewAvailableMethodsScenario([]string{"ONE-TIME PASSWORD"}))
suite.Run(t, NewStandaloneWebDriverSuite())
suite.Run(t, NewStandaloneSuite()) suite.Run(t, NewStandaloneSuite())
} }

View File

@ -14,7 +14,14 @@ func NewTraefikSuite() *TraefikSuite {
return &TraefikSuite{SeleniumSuite: new(SeleniumSuite)} return &TraefikSuite{SeleniumSuite: new(SeleniumSuite)}
} }
func TestTraefikSuite(t *testing.T) { func (s *TraefikSuite) TestOneFactorScenario() {
suite.Run(t, NewOneFactorScenario()) suite.Run(s.T(), NewOneFactorScenario())
suite.Run(t, NewTwoFactorScenario()) }
func (s *TraefikSuite) TestTwoFactorScenario() {
suite.Run(s.T(), NewTwoFactorScenario())
}
func TestTraefikSuite(t *testing.T) {
suite.Run(t, NewTraefikSuite())
} }