Skip to content

Commit

Permalink
fix(tests): Only run basic auth tests against basic auth environment …
Browse files Browse the repository at this point in the history
…and oauth tests against an oauth environment
  • Loading branch information
spbsoluble committed Oct 17, 2024
1 parent adbb9b8 commit 6f0d884
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
28 changes: 28 additions & 0 deletions auth_providers/auth_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
)

func TestBasicAuthAuthenticator_GetHttpClient(t *testing.T) {
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
return
}

auth := &auth_providers.BasicAuthAuthenticator{
Client: &http.Client{},
}
Expand All @@ -24,6 +30,11 @@ func TestBasicAuthAuthenticator_GetHttpClient(t *testing.T) {
}

func TestCommandAuthConfigBasic_ValidateAuthConfig(t *testing.T) {
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandAuthConfigBasic{
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),
Expand All @@ -36,6 +47,12 @@ func TestCommandAuthConfigBasic_ValidateAuthConfig(t *testing.T) {
}

func TestCommandAuthConfigBasic_GetHttpClient(t *testing.T) {
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
return
}

config := &auth_providers.CommandAuthConfigBasic{
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),
Expand All @@ -52,6 +69,12 @@ func TestCommandAuthConfigBasic_GetHttpClient(t *testing.T) {
}

func TestCommandAuthConfigBasic_Authenticate(t *testing.T) {
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
return
}

config := &auth_providers.CommandAuthConfigBasic{}

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

func TestCommandAuthConfigBasic_Build(t *testing.T) {
// Skip test if TEST_KEYFACTOR_KC_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_KC_AUTH") == "true" {
t.Skip("Skipping TestBasicAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandAuthConfigBasic{
Username: os.Getenv(auth_providers.EnvKeyfactorUsername),
Password: os.Getenv(auth_providers.EnvKeyfactorPassword),
Expand Down
25 changes: 25 additions & 0 deletions auth_providers/auth_oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
)

func TestOAuthAuthenticator_GetHttpClient(t *testing.T) {
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
return
}
auth := &auth_providers.OAuthAuthenticator{
Client: &http.Client{},
}
Expand All @@ -24,6 +29,11 @@ func TestOAuthAuthenticator_GetHttpClient(t *testing.T) {
}

func TestCommandConfigOauth_ValidateAuthConfig(t *testing.T) {
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandConfigOauth{
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
Expand All @@ -37,6 +47,11 @@ func TestCommandConfigOauth_ValidateAuthConfig(t *testing.T) {
}

func TestCommandConfigOauth_GetHttpClient(t *testing.T) {
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandConfigOauth{
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
Expand All @@ -55,6 +70,11 @@ func TestCommandConfigOauth_GetHttpClient(t *testing.T) {
}

func TestCommandConfigOauth_Authenticate(t *testing.T) {
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandConfigOauth{
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
Expand All @@ -69,6 +89,11 @@ func TestCommandConfigOauth_Authenticate(t *testing.T) {
}

func TestCommandConfigOauth_Build(t *testing.T) {
// Skip test if TEST_KEYFACTOR_AD_AUTH is set to 1 or true
if os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "1" || os.Getenv("TEST_KEYFACTOR_AD_AUTH") == "true" {
t.Skip("Skipping TestOAuthAuthenticator_GetHttpClient")
return
}
config := &auth_providers.CommandConfigOauth{
ClientID: os.Getenv(auth_providers.EnvKeyfactorClientID),
ClientSecret: os.Getenv(auth_providers.EnvKeyfactorClientSecret),
Expand Down

0 comments on commit 6f0d884

Please sign in to comment.