mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Updated mapping is not being picked and responded with the response #57
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 @raghavendrabankapur on GitHub (Dec 19, 2017).
Start the FluentMockServer with below settings
Now access /__admin/mappings to get the default mappings in the console application example (having guid 11111110-a633-40e8-a244-5cb80bc0ab66).
Update the pattern to /static/mapping/update
Once the mapping is updated, make a get call to localhost:1111/static/mapping/update, this will return 410 as response.
Possible issue found is when we try to find the matching mappings from the list of mappings we have. In WireMockMiddleWire.cs file in Invoke method we have a condition to to check if it's partial mappings or not. In the else loop, we are sorting the mapping object by priority and then return the IsPerfectMatch first or default value. Here we are finding another mapping with matches the above pattern with /* which is being registered when we add ProxyAndRecordSettings. So when we try to access localhost:1111/static/mapping/update it matches with /* and return 410 rather finding the other matches in the mapping.
If we can parse all the entries in the mappings object we should find the exact match for /static/mapping/update pattern also. Infact we can see in the mappings object and also the value of IsPerfectMatch being set to this result as true, but the first value which matches the pattern /* is being returned.
@raghavendrabankapur commented on GitHub (Dec 19, 2017):
The line of code which is commented in the screenshot was causing the problem. I understand this is used to record and proxy the request, but it was failing to map the request and respond accordingly
@raghavendrabankapur commented on GitHub (Dec 19, 2017):
Above highlighted place is where we find the target mapping. In the else loop we order by priority and return the first element which will be matching the pattern /* because if there is no priority set, then the default list will be present without any sorting
@raghavendrabankapur commented on GitHub (Dec 20, 2017):
@StefH I have found the solution for this. If I could create the pull request, then you can look into the fix and approve.
@StefH commented on GitHub (Dec 20, 2017):
You can make a PR and check if the unit-tests still work fine and maybe check if more tests are needed to test this scenario.
@raghavendrabankapur commented on GitHub (Dec 20, 2017):
All the tests are working fine.
I have committed my changes to master branch itself, but I do not have permissions to push my code for a PR. Could you please provide me permissions? @StefH
@StefH commented on GitHub (Dec 20, 2017):
You can just fork this project and do your change and create a PR.
@raghavendrabankapur commented on GitHub (Dec 20, 2017):
@StefH yes done.
@StefH commented on GitHub (Dec 20, 2017):
Thanks.
See new NuGet.