Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update harness api key env variable name #2775

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading