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

Fix support of blank path without trailing slash for RMQ HTTP scaler #791

Merged
merged 1 commit into from
May 5, 2020
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 pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *rabbitMQScaler) getQueueInfoViaHttp() (*queueInfo, error) {

vhost := parsedUrl.Path

if vhost == "/" || vhost == "//" {
if vhost == "" || vhost == "/" || vhost == "//" {
vhost = "/%2F"
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/scalers/rabbitmq_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ var testQueueInfoTestData = []getQueueInfoTestData{
{`Password is incorrect`, http.StatusUnauthorized, false},
}

var vhosts = []string{"myhost", "", "/", "%2F"}
var vhost_pathes = []string{"/myhost", "", "/", "//", "/%2F"}

func TestGetQueueInfo(t *testing.T) {
for _, testData := range testQueueInfoTestData {
for _, vhost := range vhosts {
expeced_vhost := vhost
for _, vhost_path := range vhost_pathes {
expeced_vhost := "myhost"

if vhost != "myhost" {
if vhost_path != "/myhost" {
expeced_vhost = "%2F"
}

Expand All @@ -89,7 +89,7 @@ func TestGetQueueInfo(t *testing.T) {
w.Write([]byte(testData.response))
}))

resolvedEnv := map[string]string{apiHost: fmt.Sprintf("%s/%s", apiStub.URL, vhost)}
resolvedEnv := map[string]string{apiHost: fmt.Sprintf("%s%s", apiStub.URL, vhost_path)}

metadata := map[string]string{
"queueLength": "10",
Expand Down