Skip to content

Commit

Permalink
trim \n suffix in Prometheus customAuth parser, add test suites and u…
Browse files Browse the repository at this point in the history
…pdate CHANGELOG

Signed-off-by: Amir-Wollman <[email protected]>
  • Loading branch information
Amir-Wollman committed Sep 11, 2023
1 parent 791c895 commit ebdb572
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Go modules cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.mod_cache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Go build cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.build_cache }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Go modules cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.mod_cache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Go build cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.build_cache }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
echo "build_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Go modules cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.mod_cache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Go build cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ steps.go-paths.outputs.build_cache }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v1-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 1

- name: Go modules cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: /go/pkg
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **General**: Update golangci-lint version documented in CONTRIBUTING.md since old version doesn't support go 1.20 (N/A)
- **General**: Updated AWS SDK and updated all the aws scalers ([#4905](https://github.com/kedacore/keda/issues/4905))
- **Azure Pod Identity**: Introduce validation to prevent usage of empty identity ID for Azure identity providers ([#4528](https://github.com/kedacore/keda/issues/4528))
- **Prometheus CustomAuth Params**: Remove trailing whitespaces in customAtuhHeader and value. ([#4960](https://github.com/kedacore/keda/issues/4960))

### Fixes
- **RabbitMQ Scaler**: Allow subpaths along with vhost in connection string ([#2634](https://github.com/kedacore/keda/issues/2634))
Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/authentication/authentication_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func GetAuthConfigs(triggerMetadata, authParams map[string]string) (out *AuthMet
if len(authParams["customAuthHeader"]) == 0 {
return nil, errors.New("no custom auth header given")
}
out.CustomAuthHeader = authParams["customAuthHeader"]
out.CustomAuthHeader = strings.TrimSuffix(authParams["customAuthHeader"], "\n")

if len(authParams["customAuthValue"]) == 0 {
return nil, errors.New("no custom auth value given")
}
out.CustomAuthValue = authParams["customAuthValue"]
out.CustomAuthValue = strings.TrimSuffix(authParams["customAuthValue"], "\n")
out.EnableCustomAuth = true
default:
return nil, fmt.Errorf("incorrect value for authMode is given: %s", t)
Expand Down
2 changes: 2 additions & 0 deletions pkg/scalers/prometheus_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ var testPrometheusAuthMetadata = []prometheusAuthMetadataTestData{
{map[string]string{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total", "threshold": "100", "query": "up", "authModes": "custom"}, map[string]string{"customAuthHeader": ""}, "", true},
// fail custom auth with no customAuthValue
{map[string]string{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total", "threshold": "100", "query": "up", "authModes": "custom"}, map[string]string{"customAuthValue": ""}, "", true},
// success custom auth with newlines in customAuthHeader
{map[string]string{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total", "threshold": "100", "query": "up", "authModes": "custom"}, map[string]string{"customAuthHeader": "header\n", "customAuthValue": "value\n"}, "", false},

{map[string]string{"serverAddress": "http://localhost:9090", "metricName": "http_requests_total", "threshold": "100", "query": "up", "authModes": "tls,basic"}, map[string]string{"username": "user", "password": "pass"}, "", true},
// pod identity and other auth modes enabled together
Expand Down

0 comments on commit ebdb572

Please sign in to comment.