2022-06-08 19:57:00 +00:00
|
|
|
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
2020-09-16 14:19:51 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2020-08-07 01:44:14 +00:00
|
|
|
|
2021-06-22 15:23:19 +00:00
|
|
|
package testlib
|
2020-08-07 01:44:14 +00:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2021-08-25 19:34:33 +00:00
|
|
|
// skipUnlessIntegration skips the current test if `-short` has been passed to `go test`.
|
|
|
|
func skipUnlessIntegration(t *testing.T) {
|
2020-08-07 01:44:14 +00:00
|
|
|
t.Helper()
|
2022-06-08 19:57:00 +00:00
|
|
|
|
2020-08-07 01:44:14 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping integration test because of '-short' flag")
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 19:57:00 +00:00
|
|
|
|
|
|
|
func SkipTestWhenLDAPIsUnavailable(t *testing.T, env *TestEnv) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
if len(env.ToolsNamespace) == 0 && !env.HasCapability(CanReachInternetLDAPPorts) {
|
|
|
|
t.Skip("LDAP integration test requires connectivity to an LDAP server")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func SkipTestWhenActiveDirectoryIsUnavailable(t *testing.T, env *TestEnv) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
if !env.HasCapability(CanReachInternetLDAPPorts) {
|
|
|
|
t.Skip("Active Directory integration test requires network connectivity to an AD server")
|
|
|
|
}
|
|
|
|
|
|
|
|
if IntegrationEnv(t).SupervisorUpstreamActiveDirectory.Host == "" {
|
|
|
|
t.Skip("Active Directory hostname not specified")
|
|
|
|
}
|
|
|
|
}
|