From d436bbdff18dcf57d4d165bda4c2eb9fce686122 Mon Sep 17 00:00:00 2001 From: Amir-Wollman Date: Mon, 11 Sep 2023 12:51:09 +0300 Subject: [PATCH 1/3] trim \n suffix in Prometheus customAuth parser, add test suites and update CHANGELOG Signed-off-by: Amir-Wollman --- CHANGELOG.md | 1 + pkg/scalers/authentication/authentication_helpers.go | 4 ++-- pkg/scalers/prometheus_scaler_test.go | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b47a94fef9d..b88bc4bfad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/pkg/scalers/authentication/authentication_helpers.go b/pkg/scalers/authentication/authentication_helpers.go index a77bc1c7333..4e5284f9c68 100644 --- a/pkg/scalers/authentication/authentication_helpers.go +++ b/pkg/scalers/authentication/authentication_helpers.go @@ -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) diff --git a/pkg/scalers/prometheus_scaler_test.go b/pkg/scalers/prometheus_scaler_test.go index 7bb8a336804..a8d71dc4759 100644 --- a/pkg/scalers/prometheus_scaler_test.go +++ b/pkg/scalers/prometheus_scaler_test.go @@ -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 From a337818b39e90ed873a9c52c9098652640f0f572 Mon Sep 17 00:00:00 2001 From: Amir-Wollman <135226062+Amir-Wollman@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:56:51 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md Fix whitespace at the end of CHANGELOG.md file Co-authored-by: Jorge Turrado Ferrero Signed-off-by: Amir-Wollman <135226062+Amir-Wollman@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b88bc4bfad8..58f3d481975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +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)) +- **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)) From 5e828c68b8022f32141741a7041db7198b2f685f Mon Sep 17 00:00:00 2001 From: Amir-Wollman <135226062+Amir-Wollman@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:23:31 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md Modify CHANGELOG entry to use correct parameter names Signed-off-by: Amir-Wollman <135226062+Amir-Wollman@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f3d481975..95839326868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +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)) +- **Prometheus Scaler**: Remove trailing whitespaces in customAuthHeader and customAuthValue ([#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))