Skip to content

Commit

Permalink
update harness api key env variable name (#2775)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <hga@yahooinc.com>
  • Loading branch information
havetisyan authored Oct 25, 2024
1 parent 4cf147c commit 275a496
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions provider/harness/sia-harness/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func generateTokenRequestBody(audience string) (io.Reader, error) {
// GetOIDCToken retrieves the OIDC token from the Harness server for the given audience
func GetOIDCToken(audience, harnessUrl string) (string, map[string]interface{}, error) {

apiToken := os.Getenv("OIDC_SA_TOKEN_SECRET_PATH")
apiToken := os.Getenv("HARNESS_OIDC_API_KEY")
if apiToken == "" {
return "", nil, fmt.Errorf("OIDC_SA_TOKEN_SECRET_PATH environment variable not set")
return "", nil, fmt.Errorf("HARNESS_OIDC_API_KEY environment variable not set")
}

// get the id token for the harness pipeline
Expand Down
8 changes: 4 additions & 4 deletions provider/harness/sia-harness/authn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGetOIDCToken(t *testing.T) {

validToken := "eyJraWQiOiJlY2tleTEiLCJhbGciOiJFUzI1NiJ9.eyJzdWIiOiJhY2NvdW50LzEyMzQ6b3JnL2F0aGVuem9yZzpwcm9qZWN0L2F0aGVuejpwaXBlbGluZS9qb2ItdXVpZCIsImF1ZCI6Imh0dHBzOi8vYXRoZW56LmlvIiwiYWNjb3VudF9pZCI6IjEyMzQiLCJwcm9qZWN0X2lkIjoiYXRoZW56Iiwib3JnYW5pemF0aW9uX2lkIjoiYXRoZW56b3JnIiwiY29udGV4dCI6InRyaWdnZXJUeXBlOm1hbnVhbC90cmlnZ2VyRXZlbnQ6bnVsbC9zZXF1ZW5jZUlkOjEiLCJpc3MiOiJodHRwczovL2F0aGVuei5oYXJuZXNzLmlvIiwicGlwZWxpbmVfaWQiOiJqb2ItdXVpZCIsImV4cCI6MTcyOTYyOTkwOCwiaWF0IjoxNzI5NjI2MzA4fQ.RLIzKol2GOfQXeCFrTyfLDgHXOGWXNvmS79VP6M2tC-XI-WNO_mh3uaytjWwWsLVTfBi7zB_n_UCsQXJOb58Sg"

os.Setenv("OIDC_SA_TOKEN_SECRET_PATH", "api-token")
os.Setenv("HARNESS_OIDC_API_KEY", "api-token")

os.Setenv("HARNESS_ACCOUNT_ID", "1234")
os.Setenv("HARNESS_ORG_ID", "athenzorg")
Expand Down Expand Up @@ -77,14 +77,14 @@ func TestGetOIDCTokenEnvNotSet(t *testing.T) {
// both env variables missing - first check is for request url
_, _, err := GetOIDCToken("https://athenz.io", "http://localhost:8081/oidc")
assert.NotNil(t, err)
assert.Equal(t, "OIDC_SA_TOKEN_SECRET_PATH environment variable not set", err.Error())
assert.Equal(t, "HARNESS_OIDC_API_KEY environment variable not set", err.Error())

os.Clearenv()
}

func TestGetOIDCTokenInvalidStatusCode(t *testing.T) {

os.Setenv("OIDC_SA_TOKEN_SECRET_PATH", "api-token")
os.Setenv("HARNESS_OIDC_API_KEY", "api-token")

os.Setenv("HARNESS_ACCOUNT_ID", "acct1")
os.Setenv("HARNESS_ORG_ID", "org2")
Expand All @@ -105,7 +105,7 @@ func TestGetOIDCTokenInvalidStatusCode(t *testing.T) {

func TestGetOIDCTokenInvalidToken(t *testing.T) {

os.Setenv("OIDC_SA_TOKEN_SECRET_PATH", "api-token")
os.Setenv("HARNESS_OIDC_API_KEY", "api-token")

os.Setenv("HARNESS_ACCOUNT_ID", "acct1")
os.Setenv("HARNESS_ORG_ID", "org2")
Expand Down

0 comments on commit 275a496

Please sign in to comment.