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

RequestMessageHeaderMatcher with MatchBehaviour.RejectOnMatch reverses match results twice #796

Closed
flts opened this issue Aug 22, 2022 · 0 comments · Fixed by #797
Closed
Labels

Comments

@flts
Copy link
Contributor

flts commented Aug 22, 2022

Describe the bug

Following the Reversing the match behaviour with MatchBehaviour.RejectOnMatch
example the reponse will always be Unauthorized even if a correct header is added on the request.

I believe the following line shouldn't call MatchBehaviourHelper.Convert() again as it is already called for each Matcher. Other RequestMessage***Matcher's do not call MatchBehaviourHelper.Convert() before returning.

return MatchBehaviourHelper.Convert(_matchBehaviour, MatchScores.ToScore(results, MatchOperator));

Expected behavior:

Given the following example taken from the docs. The expected behavior is that only an Unauthorized response is returned when the header api-key is missing from the http request.

server
   .Given(Request.Create()
             .WithPath("/needs-a-key")
             .UsingGet()
             .WithHeader("api-key", "*", MatchBehaviour.RejectOnMatch)
             .UsingAnyMethod())
   .RespondWith(Response.Create()
             .WithStatusCode(HttpStatusCode.Unauthorized)
             .WithBody(@"{ ""result"": ""api-key missing""}"));

Other related info

Since WireMock.Net v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant