Skip to content

Commit 6f0d884

Browse files
committed
fix(tests): Only run basic auth tests against basic auth environment and oauth tests against an oauth environment
1 parent adbb9b8 commit 6f0d884

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

auth_providers/auth_basic_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import (
99
)
1010

1111
func TestBasicAuthAuthenticator_GetHttpClient(t *testing.T) {
12+
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
13+
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
14+
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
15+
return
16+
}
17+
1218
auth := &auth_providers.BasicAuthAuthenticator{
1319
Client: &http.Client{},
1420
}
@@ -24,6 +30,11 @@ func TestBasicAuthAuthenticator_GetHttpClient(t *testing.T) {
2430
}
2531

2632
func TestCommandAuthConfigBasic_ValidateAuthConfig(t *testing.T) {
33+
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
34+
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
35+
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
36+
return
37+
}
2738
config := &auth_providers.CommandAuthConfigBasic{
2839
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
2940
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),
@@ -36,6 +47,12 @@ func TestCommandAuthConfigBasic_ValidateAuthConfig(t *testing.T) {
3647
}
3748

3849
func TestCommandAuthConfigBasic_GetHttpClient(t *testing.T) {
50+
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
51+
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
52+
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
53+
return
54+
}
55+
3956
config := &auth_providers.CommandAuthConfigBasic{
4057
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
4158
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),
@@ -52,6 +69,12 @@ func TestCommandAuthConfigBasic_GetHttpClient(t *testing.T) {
5269
}
5370

5471
func TestCommandAuthConfigBasic_Authenticate(t *testing.T) {
72+
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
73+
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
74+
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
75+
return
76+
}
77+
5578
config := &auth_providers.CommandAuthConfigBasic{}
5679

5780
err := config.Authenticate()
@@ -61,6 +84,11 @@ func TestCommandAuthConfigBasic_Authenticate(t *testing.T) {
6184
}
6285

6386
func TestCommandAuthConfigBasic_Build(t *testing.T) {
87+
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
88+
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
89+
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
90+
return
91+
}
6492
config := &auth_providers.CommandAuthConfigBasic{
6593
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
6694
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),

auth_providers/auth_oauth_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
)
1010

1111
func TestOAuthAuthenticator_GetHttpClient(t *testing.T) {
12+
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
13+
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
14+
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
15+
return
16+
}
1217
auth := &auth_providers.OAuthAuthenticator{
1318
Client: &http.Client{},
1419
}
@@ -24,6 +29,11 @@ func TestOAuthAuthenticator_GetHttpClient(t *testing.T) {
2429
}
2530

2631
func TestCommandConfigOauth_ValidateAuthConfig(t *testing.T) {
32+
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
33+
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
34+
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
35+
return
36+
}
2737
config := &auth_providers.CommandConfigOauth{
2838
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
2939
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
@@ -37,6 +47,11 @@ func TestCommandConfigOauth_ValidateAuthConfig(t *testing.T) {
3747
}
3848

3949
func TestCommandConfigOauth_GetHttpClient(t *testing.T) {
50+
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
51+
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
52+
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
53+
return
54+
}
4055
config := &auth_providers.CommandConfigOauth{
4156
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
4257
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
@@ -55,6 +70,11 @@ func TestCommandConfigOauth_GetHttpClient(t *testing.T) {
5570
}
5671

5772
func TestCommandConfigOauth_Authenticate(t *testing.T) {
73+
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
74+
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
75+
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
76+
return
77+
}
5878
config := &auth_providers.CommandConfigOauth{
5979
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
6080
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
@@ -69,6 +89,11 @@ func TestCommandConfigOauth_Authenticate(t *testing.T) {
6989
}
7090

7191
func TestCommandConfigOauth_Build(t *testing.T) {
92+
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
93+
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
94+
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
95+
return
96+
}
7297
config := &auth_providers.CommandConfigOauth{
7398
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
7499
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),

0 commit comments

Comments
 (0)