mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
[Admin API] Find a request that matched a given mapping #562
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 @tlevesque-ueat on GitHub (Dec 12, 2023).
Originally assigned to: @StefH on GitHub.
Maybe I'm missing something, but I can't find a way to find a request that matched a mapping, given the mapping GUID, using the Admin API.
The request body for the
POST /__admin/requests/findendpoint takes aRequestModel, butMappingGuidis a property ofLogEntryModel, so it doesn't seem like I can do it using this endpoint.The
GET /__admin/requests/{guid}endpoint takes the GUID of the request, not the mapping, so it's not helpful since I don't know the request GUID.Is there anyway to achieve what I want? It would be very useful, to avoid repeating the whole request specification to verify if a request was made.
As a workaround, I currently use
GET /__admin/requestsand check against the whole list to see if a request matched the mapping, but it's not ideal.@StefH commented on GitHub (Dec 12, 2023):
@tlevesque-ueat
Some possible options to solve this;
requests?mappingGuid=123abcWhat would be the best design?
@tlevesque-ueat commented on GitHub (Dec 12, 2023):
Hi,
Thanks for your reply.
The
MappingGuidisn't logically part of theRequestModel, so adding it there would be a bit of a hack.Ideally, the "find requests" endpoint would take an
LogEntryModel, not aRequestModel, but that would be a breaking change...I think a query parameter, as suggested in your first option, would be fine.
@StefH commented on GitHub (Dec 13, 2023):
@tlevesque-ueat
I can update the server code to support both the current
RequestModeland theLogEntryModelas an input model. That would not introduce a breaking change.@tlevesque-ueat commented on GitHub (Dec 13, 2023):
On the same endpoint? How would it differentiate between the two?
If possible, it would be perfect. And add an overload to the
FindRequestsAsyncmethod inIWireMockAdminApi@StefH commented on GitHub (Dec 16, 2023):
@tlevesque-ueat
I decided for the mappingGuid.
See PR:
https://github.com/WireMock-Net/WireMock.Net/pull/1043
An preview version
1.5.44-ci-18104can be tested.(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
@tlevesque-ueat commented on GitHub (Dec 18, 2023):
That's perfect, thanks!
However I can't really test the preview, because I use the container version of WireMock.NET, which isn't updated yet, as far as I can tell.
I don't suppose you publish preview versions of the Docker container?
@StefH commented on GitHub (Dec 18, 2023):
No, I do not have anything setup in the pipeline to also build a preview versions for docker versions.
@tlevesque-ueat commented on GitHub (Dec 18, 2023):
It's OK, I'll wait for the non-preview release. I have a workaround, so I'm not in a hurry.
@StefH commented on GitHub (Dec 22, 2023):
@tlevesque-ueat
A new version from the docker is published.
@tlevesque-ueat commented on GitHub (Dec 22, 2023):
Awesome, thanks! Will try it now
@tlevesque-ueat commented on GitHub (Dec 22, 2023):
It works fine, thanks!
Just one thing, though: it only returns one request, but there could be multiple requests that match the same mapping GUID... It would probably be better to return a collection of requests. I'll make some comments on the PR.
I should have reviewed more carefully when you made the PR, sorry about that...
@StefH commented on GitHub (Dec 22, 2023):
You can also create a PR yourself for that.
@tlevesque-ueat commented on GitHub (Dec 22, 2023):
Sure, I will. If you don't mind the breaking change (hopefully the new endpoint is recent enough that nobody is already relying on it...)
@tlevesque-ueat commented on GitHub (Dec 22, 2023):
https://github.com/WireMock-Net/WireMock.Net/pull/1046