mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Mappings to the Same Path with Multiple JmesPathMatchers Matches Incorrectly #548
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @joshua-woolf on GitHub (Oct 13, 2023).
Originally assigned to: @StefH on GitHub.
Describe the bug
Given two mappings to the same path with multiple different
JmesPathMatchermatchers on the body, the incorrect match is returned depending on the order of the mapping in the mapping file.Expected behavior:
The response for the request where all matchers match should be returned.
Test to reproduce
There are 4 example tests included here:
Setup static mappings as follows:
Run the dotnet global tool as follows (version 1.5.39):
Run the following PowerShell code to see results:
Results show:
@StefH commented on GitHub (Oct 13, 2023):
@joshua-woolf
I think the internal logic defaults to
ORbecause the MatchOperator should be case-sensitive.Can you try using the value
Andinstead ofand?@StefH commented on GitHub (Oct 13, 2023):
https://github.com/WireMock-Net/WireMock.Net/pull/1009
@joshua-woolf commented on GitHub (Oct 16, 2023):
@StefH
I can confirm that changing the casing of
andtoAnddoes cause Example A to pass, however Example C still fails.@StefH commented on GitHub (Oct 16, 2023):
@joshua-woolf
The current implementation has no logic yet to determine that in your case the
Example_C_Passmatch is the best of the two "C"-tests.For now just use
.AtPriority(...)--> give theExample_C_Passa value of 1, and the other a value of 2 or higher.See https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing#stub-priority