mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Reset single scenario using HTTP request #460
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 @iparry7979 on GitHub (Oct 19, 2022).
I am running WireMock as a standalone app.
Regarding resetting scenarios: I am able to reset all scenarios using an empty POST request such as: POST /__admin/scenarios/reset.
However, it fails when I try to reset a single scenario using an empty PUT request for example: PUT /__admin/scenarios/my_scenario/state
According to the documentation here this should work in the java version. Is this implemented in the C# version? If so am I doing something wrong to reset a single scenario?
@StefH commented on GitHub (Oct 19, 2022):
Hello @iparry7979,
This is not yet implemented in the current version, however you can try a preview version which supports:
/__admin/scenarios/ABC/__admin/scenarios/ABC/resetWhere
ABCis the name from the scenario.Preview version = "1.5.8-ci-16566".
Info: https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@StefH commented on GitHub (Oct 21, 2022):
https://github.com/WireMock-Net/WireMock.Net/pull/834
@StefH commented on GitHub (Oct 22, 2022):
@iparry7979 did you have to time to verify this logic in the preview NuGet ?
@StefH commented on GitHub (Oct 25, 2022):
@iparry7979 Did you have time to test this?
@iparry7979 commented on GitHub (Oct 25, 2022):
Hi @StefH I have done some testing with this preview version. It's not working quite as I expected. I have the following stubs:
server.Given(Request.Create().WithPath("/scenario").UsingGet()).InScenario("Scenario1").WillSetStateTo("State2") .RespondWith(Response.Create().WithStatusCode(200).WithHeader("Content-Type", "text/plain").WithBody("Initial state"));server.Given(Request.Create().WithPath("/scenario").UsingGet()).InScenario("Scenario1").WhenStateIs("State2").WillSetStateTo("State3").RespondWith(Response.Create().WithStatusCode(200).WithHeader("Content-Type", "text/plain").WithBody("State 2"));server.Given(Request.Create().WithPath("/scenario").UsingGet()).InScenario("Scenario1").WhenStateIs("State3") .RespondWith(Response.Create().WithStatusCode(200).WithHeader("Content-Type", "text/plain").WithBody("State 3"));What I was expecting was that when I hit the /scenario path multiple times I would get the following responses:
Initial state
State 2
State 3
State 3
State 3
...
Since when the scenario is in state 3 there is no WillSetStateTo. What I actually got as responses was:
Initial state
State 2
State 3
Initial state
State 2
State 3
...
So the on the 3rd call it set the state back to the initial state despite having no instruction to reset the state. I also tested the POST to /__admin/scenarios/ABC/reset. Here were the results:
C:\Developer>curl http://localhost:7979/scenarioInitial stateC:\Developer>curl -X POST http://localhost:7979/__admin/scenarios/Scenario1/resetState 2C:\Developer>curl http://localhost:7979/scenarioState 3So the POST to the admin url seemed to just do the same thing as a call to the /scenario path and updated the state to state3. Whereas I expected it should reset the scenario to it's initial state. I may be misunderstanding something about the way it is supposed to work though.
@iparry7979 commented on GitHub (Oct 25, 2022):
@StefH Please disregard the second part of my comment above. I had updated Wiremock.Net.Standalone but not WireMock.Net. When I updated the package the POST to /__admin/scenarios/Scenario1/reset worked as expected in version 1.5.8-ci-16566.
@StefH commented on GitHub (Oct 26, 2022):
@iparry7979 Thanks for testing. I'll merge PR to master en close this issue.