test(suites): short mode skip suites testing (#1823)

This PR changes the suites tests so if go test -short is used, they are skipped per go standards and a message is displayed. Additionally removed some redundant types from suite_high_availability_test.go and adjusted a warning about a nil req var.
This commit is contained in:
James Elliott 2021-03-14 18:08:26 +11:00 committed by GitHub
parent 4f5bda768b
commit a0248cd096
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 148 additions and 12 deletions

View File

@ -66,5 +66,9 @@ func (s *BackendProtectionScenario) TestInvalidEndpointsReturn404() {
} }
func TestRunBackendProtection(t *testing.T) { func TestRunBackendProtection(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewBackendProtectionScenario()) suite.Run(t, NewBackendProtectionScenario())
} }

View File

@ -59,5 +59,9 @@ func (s *BypassPolicyScenario) TestShouldAccessPublicResource() {
} }
func TestBypassPolicyScenario(t *testing.T) { func TestBypassPolicyScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewBypassPolicyScenario()) suite.Run(t, NewBypassPolicyScenario())
} }

View File

@ -125,5 +125,9 @@ func (s *CustomHeadersScenario) TestShouldForwardCustomHeaderForAuthenticatedUse
} }
func TestCustomHeadersScenario(t *testing.T) { func TestCustomHeadersScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewCustomHeadersScenario()) suite.Run(t, NewCustomHeadersScenario())
} }

View File

@ -65,5 +65,9 @@ func (drus *DefaultRedirectionURLScenario) TestUserIsRedirectedToDefaultURL() {
} }
func TestShouldRunDefaultRedirectionURLScenario(t *testing.T) { func TestShouldRunDefaultRedirectionURLScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewDefaultRedirectionURLScenario()) suite.Run(t, NewDefaultRedirectionURLScenario())
} }

View File

@ -115,5 +115,9 @@ func (s *InactivityScenario) TestShouldDisableCookieExpirationAndInactivity() {
} }
func TestInactivityScenario(t *testing.T) { func TestInactivityScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewInactivityScenario()) suite.Run(t, NewInactivityScenario())
} }

View File

@ -76,5 +76,9 @@ func (s *OneFactorSuite) TestShouldDenyAccessOnBadPassword() {
} }
func TestRunOneFactor(t *testing.T) { func TestRunOneFactor(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewOneFactorScenario()) suite.Run(t, NewOneFactorScenario())
} }

View File

@ -57,5 +57,9 @@ func (s *PasswordComplexityScenario) TestShouldRejectPasswordReset() {
} }
func TestRunPasswordComplexityScenario(t *testing.T) { func TestRunPasswordComplexityScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewPasswordComplexityScenario()) suite.Run(t, NewPasswordComplexityScenario())
} }

View File

@ -78,5 +78,9 @@ func (s *RedirectionCheckScenario) TestShouldRedirectOnlyWhenDomainIsHandledByAu
} }
func TestRedirectionCheckScenario(t *testing.T) { func TestRedirectionCheckScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewRedirectionCheckScenario()) suite.Run(t, NewRedirectionCheckScenario())
} }

View File

@ -58,5 +58,9 @@ func (rus *RedirectionURLScenario) TestShouldVerifyCustomURLParametersArePropaga
} }
func TestRedirectionURLScenario(t *testing.T) { func TestRedirectionURLScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewRedirectionURLScenario()) suite.Run(t, NewRedirectionURLScenario())
} }

View File

@ -83,5 +83,9 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() {
} }
func TestBlacklistingScenario(t *testing.T) { func TestBlacklistingScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewRegulationScenario()) suite.Run(t, NewRegulationScenario())
} }

View File

@ -97,5 +97,9 @@ func (s *ResetPasswordScenario) TestShouldLetUserNoticeThereIsAPasswordMismatch(
} }
func TestRunResetPasswordScenario(t *testing.T) { func TestRunResetPasswordScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewResetPasswordScenario()) suite.Run(t, NewResetPasswordScenario())
} }

View File

@ -59,5 +59,9 @@ func (s *SigninEmailScenario) TestShouldSignInWithUserEmail() {
} }
func TestSigninEmailScenario(t *testing.T) { func TestSigninEmailScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewSigninEmailScenario()) suite.Run(t, NewSigninEmailScenario())
} }

View File

@ -98,5 +98,9 @@ func (s *TwoFactorSuite) TestShouldFailTwoFactor() {
} }
func TestRunTwoFactor(t *testing.T) { func TestRunTwoFactor(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewTwoFactorScenario()) suite.Run(t, NewTwoFactorScenario())
} }

View File

@ -94,5 +94,9 @@ func (s *UserPreferencesScenario) TestShouldRememberLastUsed2FAMethod() {
} }
func TestUserPreferencesScenario(t *testing.T) { func TestUserPreferencesScenario(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewUserPreferencesScenario()) suite.Run(t, NewUserPreferencesScenario())
} }

View File

@ -35,5 +35,9 @@ func (s *ActiveDirectorySuite) TestSigninEmailScenario() {
} }
func TestActiveDirectorySuite(t *testing.T) { func TestActiveDirectorySuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewActiveDirectorySuite()) suite.Run(t, NewActiveDirectorySuite())
} }

View File

@ -64,5 +64,9 @@ func (s *BypassAllSuite) TestCustomHeadersScenario() {
} }
func TestBypassAllSuite(t *testing.T) { func TestBypassAllSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewBypassAllSuite()) suite.Run(t, NewBypassAllSuite())
} }

View File

@ -143,5 +143,9 @@ func (s *CLISuite) TestShouldGenerateCertificateECDSAP521() {
} }
func TestCLISuite(t *testing.T) { func TestCLISuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewCLISuite()) suite.Run(t, NewCLISuite())
} }

View File

@ -23,5 +23,9 @@ func (s *DockerSuite) TestTwoFactorScenario() {
} }
func TestDockerSuite(t *testing.T) { func TestDockerSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewDockerSuite()) suite.Run(t, NewDockerSuite())
} }

View File

@ -145,5 +145,9 @@ func (s *DuoPushSuite) TestUserPreferencesScenario() {
} }
func TestDuoPushSuite(t *testing.T) { func TestDuoPushSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewDuoPushSuite()) suite.Run(t, NewDuoPushSuite())
} }

View File

@ -27,5 +27,9 @@ func (s *HAProxySuite) TestCustomHeaders() {
} }
func TestHAProxySuite(t *testing.T) { func TestHAProxySuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewHAProxySuite()) suite.Run(t, NewHAProxySuite())
} }

View File

@ -183,38 +183,38 @@ var UserHarry = "harry"
var Users = []string{UserJohn, UserBob, UserHarry} var Users = []string{UserJohn, UserBob, UserHarry}
var expectedAuthorizations = map[string](map[string]bool){ var expectedAuthorizations = map[string](map[string]bool){
fmt.Sprintf("%s/secret.html", PublicBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", PublicBaseURL): {
UserJohn: true, UserBob: true, UserHarry: true, UserJohn: true, UserBob: true, UserHarry: true,
}, },
fmt.Sprintf("%s/secret.html", SecureBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", SecureBaseURL): {
UserJohn: true, UserBob: true, UserHarry: true, UserJohn: true, UserBob: true, UserHarry: true,
}, },
fmt.Sprintf("%s/secret.html", AdminBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", AdminBaseURL): {
UserJohn: true, UserBob: false, UserHarry: false, UserJohn: true, UserBob: false, UserHarry: false,
}, },
fmt.Sprintf("%s/secret.html", SingleFactorBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", SingleFactorBaseURL): {
UserJohn: true, UserBob: true, UserHarry: true, UserJohn: true, UserBob: true, UserHarry: true,
}, },
fmt.Sprintf("%s/secret.html", MX1MailBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", MX1MailBaseURL): {
UserJohn: true, UserBob: true, UserHarry: false, UserJohn: true, UserBob: true, UserHarry: false,
}, },
fmt.Sprintf("%s/secret.html", MX2MailBaseURL): map[string]bool{ fmt.Sprintf("%s/secret.html", MX2MailBaseURL): {
UserJohn: false, UserBob: true, UserHarry: false, UserJohn: false, UserBob: true, UserHarry: false,
}, },
fmt.Sprintf("%s/groups/admin/secret.html", DevBaseURL): map[string]bool{ fmt.Sprintf("%s/groups/admin/secret.html", DevBaseURL): {
UserJohn: true, UserBob: false, UserHarry: false, UserJohn: true, UserBob: false, UserHarry: false,
}, },
fmt.Sprintf("%s/groups/dev/secret.html", DevBaseURL): map[string]bool{ fmt.Sprintf("%s/groups/dev/secret.html", DevBaseURL): {
UserJohn: true, UserBob: true, UserHarry: false, UserJohn: true, UserBob: true, UserHarry: false,
}, },
fmt.Sprintf("%s/users/john/secret.html", DevBaseURL): map[string]bool{ fmt.Sprintf("%s/users/john/secret.html", DevBaseURL): {
UserJohn: true, UserBob: false, UserHarry: false, UserJohn: true, UserBob: false, UserHarry: false,
}, },
fmt.Sprintf("%s/users/harry/secret.html", DevBaseURL): map[string]bool{ fmt.Sprintf("%s/users/harry/secret.html", DevBaseURL): {
UserJohn: true, UserBob: false, UserHarry: true, UserJohn: true, UserBob: false, UserHarry: true,
}, },
fmt.Sprintf("%s/users/bob/secret.html", DevBaseURL): map[string]bool{ fmt.Sprintf("%s/users/bob/secret.html", DevBaseURL): {
UserJohn: true, UserBob: true, UserHarry: false, UserJohn: true, UserBob: true, UserHarry: false,
}, },
} }
@ -264,8 +264,8 @@ func NewHighAvailabilitySuite() *HighAvailabilitySuite {
func DoGetWithAuth(t *testing.T, username, password string) int { func DoGetWithAuth(t *testing.T, username, password string) int {
client := NewHTTPClient() client := NewHTTPClient()
req, err := http.NewRequest("GET", fmt.Sprintf("%s/secret.html", SingleFactorBaseURL), nil) req, err := http.NewRequest("GET", fmt.Sprintf("%s/secret.html", SingleFactorBaseURL), nil)
req.SetBasicAuth(username, password)
assert.NoError(t, err) assert.NoError(t, err)
req.SetBasicAuth(username, password)
res, err := client.Do(req) res, err := client.Do(req)
assert.NoError(t, err) assert.NoError(t, err)
@ -304,9 +304,17 @@ func (s *HighAvailabilitySuite) TestHighAvailabilityWebDriverSuite() {
} }
func TestHighAvailabilityWebDriverSuite(t *testing.T) { func TestHighAvailabilityWebDriverSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewHighAvailabilityWebDriverSuite()) suite.Run(t, NewHighAvailabilityWebDriverSuite())
} }
func TestHighAvailabilitySuite(t *testing.T) { func TestHighAvailabilitySuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewHighAvailabilitySuite()) suite.Run(t, NewHighAvailabilitySuite())
} }

View File

@ -27,5 +27,9 @@ func (s *KubernetesSuite) TestRedirectionURLScenario() {
} }
func TestKubernetesSuite(t *testing.T) { func TestKubernetesSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewKubernetesSuite()) suite.Run(t, NewKubernetesSuite())
} }

View File

@ -35,5 +35,9 @@ func (s *LDAPSuite) TestSigninEmailScenario() {
} }
func TestLDAPSuite(t *testing.T) { func TestLDAPSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewLDAPSuite()) suite.Run(t, NewLDAPSuite())
} }

View File

@ -23,5 +23,9 @@ func (s *MariadbSuite) TestTwoFactorScenario() {
} }
func TestMariadbSuite(t *testing.T) { func TestMariadbSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewMariadbSuite()) suite.Run(t, NewMariadbSuite())
} }

View File

@ -23,5 +23,9 @@ func (s *MySQLSuite) TestTwoFactorScenario() {
} }
func TestMySQLSuite(t *testing.T) { func TestMySQLSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewMySQLSuite()) suite.Run(t, NewMySQLSuite())
} }

View File

@ -77,5 +77,9 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon0FA() {
} }
func TestNetworkACLSuite(t *testing.T) { func TestNetworkACLSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewNetworkACLSuite()) suite.Run(t, NewNetworkACLSuite())
} }

View File

@ -80,5 +80,9 @@ func (s *OneFactorOnlySuite) TestWeb() {
} }
func TestOneFactorOnlySuite(t *testing.T) { func TestOneFactorOnlySuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, new(OneFactorOnlySuite)) suite.Run(t, new(OneFactorOnlySuite))
} }

View File

@ -31,5 +31,9 @@ func (s *PathPrefixSuite) TestResetPasswordScenario() {
} }
func TestPathPrefixSuite(t *testing.T) { func TestPathPrefixSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewPathPrefixSuite()) suite.Run(t, NewPathPrefixSuite())
} }

View File

@ -23,5 +23,9 @@ func (s *PostgresSuite) TestTwoFactorScenario() {
} }
func TestPostgresSuite(t *testing.T) { func TestPostgresSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewPostgresSuite()) suite.Run(t, NewPostgresSuite())
} }

View File

@ -27,5 +27,9 @@ func (s *ShortTimeoutsSuite) TestRegulationScenario() {
} }
func TestShortTimeoutsSuite(t *testing.T) { func TestShortTimeoutsSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewShortTimeoutsSuite()) suite.Run(t, NewShortTimeoutsSuite())
} }

View File

@ -213,5 +213,9 @@ func (s *StandaloneSuite) TestRedirectionURLScenario() {
} }
func TestStandaloneSuite(t *testing.T) { func TestStandaloneSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewStandaloneSuite()) suite.Run(t, NewStandaloneSuite())
} }

View File

@ -58,5 +58,9 @@ func (s *Traefik2Suite) TestShouldKeepSessionAfterRedisRestart() {
} }
func TestTraefik2Suite(t *testing.T) { func TestTraefik2Suite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewTraefik2Suite()) suite.Run(t, NewTraefik2Suite())
} }

View File

@ -31,5 +31,9 @@ func (s *TraefikSuite) TestCustomHeaders() {
} }
func TestTraefikSuite(t *testing.T) { func TestTraefikSuite(t *testing.T) {
if testing.Short() {
t.Skip("skipping suite test in short mode")
}
suite.Run(t, NewTraefikSuite()) suite.Run(t, NewTraefikSuite())
} }