Skip to content

Add Fix to solace endpointURL to query escape special character from queueName #4940

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

Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### Fixes

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))
- **Solace Scaler**: Fix a bug where `queueName` is not properly escaped during URL encode ([#4936](https://github.com/kedacore/keda/issues/4936))

### Deprecations

Expand Down
4 changes: 3 additions & 1 deletion pkg/scalers/solace_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"

Expand Down Expand Up @@ -252,7 +253,8 @@ func parseSolaceMetadata(config *ScalerConfig) (*SolaceMetadata, error) {
solaceAPIVersion,
meta.messageVpn,
solaceAPIObjectTypeQueue,
meta.queueName)
url.QueryEscape(meta.queueName),
)

// Get Credentials
var e error
Expand Down
25 changes: 24 additions & 1 deletion pkg/scalers/solace_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
"testing"

v2 "k8s.io/api/autoscaling/v2"
Expand Down Expand Up @@ -246,6 +248,23 @@ var testParseSolaceMetadata = []testSolaceMetadata{
1,
true,
},
// +Case - Properly encode queueName
{
"#016 - Properly Encode QueueName- ",
map[string]string{
"": "",
solaceMetaSempBaseURL: soltestValidBaseURL,
solaceMetaMsgVpn: soltestValidVpn,
solaceMetaUsernameFromEnv: "",
solaceMetaPasswordFromEnv: "",
solaceMetaUsername: soltestValidUsername,
solaceMetaPassword: soltestValidPassword,
solaceMetaQueueName: "with/slash",
solaceMetaMsgCountTarget: soltestValidMsgCountTarget,
},
1,
false,
},
}

var testSolaceEnvCreds = []testSolaceMetadata{
Expand Down Expand Up @@ -513,7 +532,7 @@ var testSolaceExpectedMetricNames = map[string]string{
func TestSolaceParseSolaceMetadata(t *testing.T) {
for _, testData := range testParseSolaceMetadata {
fmt.Print(testData.testID)
_, err := parseSolaceMetadata(&ScalerConfig{ResolvedEnv: nil, TriggerMetadata: testData.metadata, AuthParams: nil, ScalerIndex: testData.scalerIndex})
meta, err := parseSolaceMetadata(&ScalerConfig{ResolvedEnv: nil, TriggerMetadata: testData.metadata, AuthParams: nil, ScalerIndex: testData.scalerIndex})
switch {
case err != nil && !testData.isError:
t.Error("expected success but got error: ", err)
Expand All @@ -524,6 +543,10 @@ func TestSolaceParseSolaceMetadata(t *testing.T) {
default:
fmt.Println(" --> PASS")
}
if !testData.isError && strings.Contains(testData.metadata["queueName"], "/") && !strings.Contains(meta.endpointURL, url.QueryEscape(testData.metadata["queueName"])) {
t.Error("expected endpointURL to query escape special characters in the URL but got:", meta.endpointURL)
fmt.Println(" --> FAIL")
}
}
for _, testData := range testSolaceEnvCreds {
fmt.Print(testData.testID)
Expand Down