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

Updated mapping is not being picked and responded with the response #73

Closed
raghavendrabankapur opened this issue Dec 19, 2017 · 8 comments

Comments

@raghavendrabankapur
Copy link
Collaborator

Start the FluentMockServer with below settings

string url = "https://localhost:1111/";
var server = FluentMockServer.Start(new FluentMockServerSettings
            {
                Urls = new[] { url },
                StartAdminInterface = true,
                ReadStaticMappings = true,
                ProxyAndRecordSettings = new ProxyAndRecordSettings
                {
                    Url = "https://www.google.com",
                    SaveMapping = true
                }
            });

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
Copy link
Collaborator Author

image

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
Copy link
Collaborator Author

raghavendrabankapur commented Dec 19, 2017

image

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
Copy link
Collaborator Author

@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
Copy link
Collaborator

StefH commented 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
Copy link
Collaborator Author

raghavendrabankapur commented 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
Copy link
Collaborator

StefH commented Dec 20, 2017

You can just fork this project and do your change and create a PR.

@raghavendrabankapur
Copy link
Collaborator Author

@StefH yes done.

@StefH
Copy link
Collaborator

StefH commented Dec 20, 2017

Thanks.

See new NuGet.

@StefH StefH closed this as completed Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants