mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Reset in WireMock admin API not working fine. #225
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 @beloquintana on GitHub (Oct 30, 2019).
Originally assigned to: @StefH on GitHub.
Reset service should reset all mappings, but it delete all stub mappings.
How could I reset mappings via web API ?
@StefH commented on GitHub (Oct 30, 2019):
What do you expect when you reset the mappings?
(Or do you ask this for scenarios?)
@beloquintana commented on GitHub (Oct 30, 2019):
When I reset the mappings, I expect that every change in the stub mappings will be applied.
For example to add a new stub mapping, I create the mappings file, then I have to reset my wiremock service to have these changes.
I think that is better to use the Admin API to reset mappings changes that reset the wiremock service.
@StefH commented on GitHub (Oct 30, 2019):
Not quite sure if I follow, could it be that you want to:
?
@beloquintana commented on GitHub (Oct 30, 2019):
I want to:
The new mappings are not added to wiremock If I do not reset my wiremock service (without using Admin API).
My mapping folder is like:
@StefH commented on GitHub (Oct 30, 2019):
Ah I see. I am not sure if the mapping json files are found if these are present in sub folders. Did you try to copy the files directly in the mapping a folder?
@beloquintana commented on GitHub (Oct 31, 2019):
The mapping json files are found when I reset the Wiremock server, but not when I call reset from Admin API.
@StefH commented on GitHub (Oct 31, 2019):
when I reset the Wiremock server,--> do you mean you just restart the WireMock server?@beloquintana commented on GitHub (Oct 31, 2019):
Yes, I also implemented a custom IFileSystemHandler, but the point is how to update the mappings with the new changes without restart the WireMock server.
@StefH commented on GitHub (Oct 31, 2019):
the EnhancedFileSystemWatcher which is used to detect changes, can only read from the
FileSystemHandler.GetMappingFolder()folder. Adding a configuration setting to also read recursive folders could be a solution for your problemAdding a Admin API call like "Refresh" / "RefreshStaticMappings" which calls the
FileSystemHandler.EnumerateFiles(...)would also be a solution for your question.@beloquintana commented on GitHub (Oct 31, 2019):
Great!!, I think that both solution will be very useful.
@StefH commented on GitHub (Oct 31, 2019):
I keep this issue open until it's fixed.
@StefH commented on GitHub (Oct 31, 2019):
You can try new package from MyGet:
WireMock.Net.1.0.37-ci-12144.nupkg
And set WatchStaticMappingsInSubdirectories to true in the settings.
@beloquintana commented on GitHub (Nov 1, 2019):
I tested WireMock.Net.1.0.37-ci-12144.nupkg and I find this bug:
New mappings are added, but It never delete the old changes until I restart WireMock server.
Steps to reproduce:
(map2.json is added correctly to wiremock)
Actual Result:
Wiremock shows 3 mappings:
map1
map2 old version
map2 new version
Expected Result:
Wiremock shows 2 mappings:
map1
map2 new version
@StefH commented on GitHub (Nov 1, 2019):
Question, for step 4; how do you edit map2.json ? Via an editor directly? Or via a PUT on the admin interface?
@beloquintana commented on GitHub (Nov 1, 2019):
Via a text editor directly
@StefH commented on GitHub (Nov 1, 2019):
This is a different thing.
If you just have a mapping file named
map1.json, and this file does not define the Guid property, a new mapping is added when you edit this file in an editor.There are 2 solutions for this:
791a3f31-6946-4ce7-8e6f-0237c7443275.json@StefH commented on GitHub (Nov 1, 2019):
https://github.com/WireMock-Net/WireMock.Net/pull/374
@beloquintana commented on GitHub (Nov 1, 2019):
Thanks for the WatchStaticMappingsInSubdirectories.
I think that define a Guid in a text editor is tricky and it is not intuitive.
If we could define an Id without any restriccion (Example: string id) would be easy to add and edit mapping json files via text editor.
Would it be possible to do?
@StefH commented on GitHub (Nov 1, 2019):
Sorry. The internal logic is using these guids.
Normally when adding a mapping via the admin API, the guid is assigned and stored in the mapping file when it's saved. Also when proxying, the guide is defined.
@StefH commented on GitHub (Nov 2, 2019):
I've also added an extra parameter to the
ResetAPI method:POST example = to
http://{{wm_hostname}}/__admin/mappings/reset?reloadStaticMappings=trueWhich will reload the static mappings after a reset (=delete) from the mappings.
A preview NuGet can be found at MyGet --> WireMock.Net.1.0.37-ci-12153.nupkg
@StefH commented on GitHub (Nov 5, 2019):
Is this ok?
@beloquintana commented on GitHub (Nov 6, 2019):
This change is only for WireMock.Net.StandAlone?
WireMock.Net.1.0.37-ci-12153.nupkg is the StandAlone
@StefH commented on GitHub (Nov 6, 2019):
Both nuget packages should be there with that 1.0.37-ci-12153 identifier.
In your case, for testing you can use either package.
@beloquintana commented on GitHub (Nov 7, 2019):
It is work very well! I will use this functionality a lot.
Thanks you!!!