Skip to content

Commit

Permalink
Merge pull request #57 from quii/issue-56
Browse files Browse the repository at this point in the history
Issue #56
  • Loading branch information
quii authored Jul 25, 2019
2 parents 574f614 + c7d774e commit d60fc74
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.9.4

RUN apk add --update wget bash ca-certificates && \
wget -O mockingjay-server https://github.com/quii/mockingjay-server/releases/download/1.11.1/linux_amd64_mockingjay-server --no-check-certificate && \
wget -O mockingjay-server https://github.com/quii/mockingjay-server/releases/download/1.11.2/linux_amd64_mockingjay-server --no-check-certificate && \
chmod +x mockingjay-server && \
apk del wget bash && \
rm -rf /var/cache/apk/*
Expand Down
11 changes: 11 additions & 0 deletions mockingjay/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ func matchURI(serverURI string, serverRegex *RegexField, incomingURI string) boo
return true
} else if serverRegex != nil {
return serverRegex.MatchString(incomingURI)
} else {
inURL, err := url.Parse(incomingURI)
expectedURL, err := url.Parse(serverURI)

if err != nil {
return false
}

if reflect.DeepEqual(inURL.Query(), expectedURL.Query()) {
return inURL.Path == expectedURL.Path
}
}
return false
}
Expand Down
14 changes: 14 additions & 0 deletions mockingjay/requestmatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,17 @@ func TestItIgnoresHeadersKeyCasing(t *testing.T) {

assert.True(t, requestMatches(expectedRequest, incomingRequest, endpointName, testLogger))
}

func TestItIgnoresOrderOfQueryString(t *testing.T) {
expectedRequest := Request{
URI: "?a=1&b=2",
Method: "GET",
}

incomingRequest := Request{
URI: "?b=2&a=1",
Method: "GET",
}

assert.True(t, requestMatches(expectedRequest, incomingRequest, endpointName, testLogger))
}

0 comments on commit d60fc74

Please sign in to comment.