-
Notifications
You must be signed in to change notification settings - Fork 928
/
client_credentials.go
54 lines (41 loc) · 1.46 KB
/
client_credentials.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package helpers
import (
"os"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
// SkipIfClientCredentialsNotSet will skip the test when either
// CF_INT_CLIENT_ID or CF_INT_CLIENT_SECRET are not set.
func SkipIfClientCredentialsNotSet() (string, string) {
privateClientID := os.Getenv("CF_INT_CLIENT_ID")
privateClientSecret := os.Getenv("CF_INT_CLIENT_SECRET")
if privateClientID == "" || privateClientSecret == "" {
Skip("CF_INT_CLIENT_ID or CF_INT_CLIENT_SECRET is not set")
}
return privateClientID, privateClientSecret
}
// SkipIfCustomClientCredentialsNotSet will skip the test when either
// CF_INT_CUSTOM_CLIENT_ID or CF_INT_CUSTOM_CLIENT_SECRET are not set.
func SkipIfCustomClientCredentialsNotSet() (string, string) {
customClientID := os.Getenv("CF_INT_CUSTOM_CLIENT_ID")
customClientSecret := os.Getenv("CF_INT_CUSTOM_CLIENT_SECRET")
if customClientID == "" || customClientSecret == "" {
Skip("CF_INT_CUSTOM_CLIENT_ID or CF_INT_CUSTOM_CLIENT_SECRET is not set")
}
return customClientID, customClientSecret
}
func SkipIfClientCredentialsTestMode() {
if ClientCredentialsTestMode() {
Skip("CF_INT_CLIENT_CREDENTIALS_TEST_MODE is enabled")
}
}
func ClientCredentialsTestMode() bool {
envVar := os.Getenv("CF_INT_CLIENT_CREDENTIALS_TEST_MODE")
if envVar == "" {
return false
}
testMode, err := strconv.ParseBool(envVar)
Expect(err).ToNot(HaveOccurred(), "CF_INT_CLIENT_CREDENTIALS_TEST_MODE should be boolean")
return testMode
}