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

[Admin API] Find a request that matched a given mapping #1039

Closed
tlevesque-ueat opened this issue Dec 12, 2023 · 14 comments
Closed

[Admin API] Find a request that matched a given mapping #1039

tlevesque-ueat opened this issue Dec 12, 2023 · 14 comments
Assignees
Labels

Comments

@tlevesque-ueat
Copy link
Contributor

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/find endpoint takes a RequestModel, but MappingGuid is a property of LogEntryModel, 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/requests and check against the whole list to see if a request matched the mapping, but it's not ideal.

@StefH StefH self-assigned this Dec 12, 2023
@StefH
Copy link
Collaborator

StefH commented Dec 12, 2023

@tlevesque-ueat

Some possible options to solve this;

  1. I can add a new GET request like requests?mappingGuid=123abc
  2. I can add the MappingGuid as nullable Guid to the RequestModel

What would be the best design?

@tlevesque-ueat
Copy link
Contributor Author

Hi,

Thanks for your reply.

The MappingGuid isn't logically part of the RequestModel, so adding it there would be a bit of a hack.
Ideally, the "find requests" endpoint would take an LogEntryModel, not a RequestModel, but that would be a breaking change...
I think a query parameter, as suggested in your first option, would be fine.

@StefH
Copy link
Collaborator

StefH commented Dec 13, 2023

@tlevesque-ueat
I can update the server code to support both the current RequestModel and the LogEntryModel as an input model. That would not introduce a breaking change.

@tlevesque-ueat
Copy link
Contributor Author

I can update the server code to support both the current RequestModel and the LogEntryModel as an input model. That would not introduce a breaking change.

On the same endpoint? How would it differentiate between the two?
If possible, it would be perfect. And add an overload to the FindRequestsAsync method in IWireMockAdminApi

@StefH StefH added feature and removed question labels Dec 16, 2023
@StefH
Copy link
Collaborator

StefH commented Dec 16, 2023

@tlevesque-ueat
I decided for the mappingGuid.

See PR:
#1043

An preview version 1.5.44-ci-18104 can be tested.
(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@tlevesque-ueat
Copy link
Contributor Author

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

StefH commented Dec 18, 2023

I don't suppose you publish preview versions of the Docker container?

No, I do not have anything setup in the pipeline to also build a preview versions for docker versions.

@tlevesque-ueat
Copy link
Contributor Author

It's OK, I'll wait for the non-preview release. I have a workaround, so I'm not in a hurry.

@StefH StefH closed this as completed Dec 21, 2023
@StefH
Copy link
Collaborator

StefH commented Dec 22, 2023

@tlevesque-ueat
A new version from the docker is published.

@tlevesque-ueat
Copy link
Contributor Author

Awesome, thanks! Will try it now

@tlevesque-ueat
Copy link
Contributor Author

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

StefH commented Dec 22, 2023

You can also create a PR yourself for that.

@tlevesque-ueat
Copy link
Contributor Author

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

#1046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants