mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Feature: add URL assertion excluding query parameters #639
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 @asos-jamiestollery on GitHub (Oct 9, 2024).
Originally assigned to: @StefH on GitHub.
Is your feature request related to a problem? Please describe.
There is no way to assert that a
WireMockServerhas been called at a URL excluding query parameters.Given my
WireMockServerhas been called athttps://localhost:8080/api/endpoint/?param1=1¶m2=2I would like to be able to do the following assertion
wireMockServer.Should().HaveReceivedACall().AtUrl("https://localhost:8080/api/endpoint/");However, this will fail as the URL does not contain the query parameters.
Describe the solution you'd like
I propose that an optional
System.UriPartialparameter is added to theWireMockAssertions.AtUrlmethod so I could assert like sowireMockServer.Should().HaveReceivedACall().AtUrl("https://localhost:8080/api/endpoint/", UriPartial.Path);This param could then be used by the method to only check the specified part of the URL like so
Uri.GetLeftPart(UriPartial.Path);Describe alternatives you've considered
Alternatively a new
WireMockAssertions.AtPathmethod could be created that checks the mock has been called at a URL excluding the query params.Additional context
I would like to implement this change myself if it is accepted as a feature
@StefH commented on GitHub (Oct 9, 2024):
Maybe adding an overload which accepts a WildcardMatcher could also solve your issue?
@asos-jamiestollery commented on GitHub (Oct 10, 2024):
Yes that would work! That would also allow for the query parameters to be validated, nice.
@StefH Just to confirm, are you happy for me to progress with the change to add an overload to the
WireMockAssertions.AtUrlmethod that takes aWildcardMatcherobject to validate the URL against?@StefH commented on GitHub (Oct 10, 2024):
Yes you can make a PR.
Also include a unit test.
@StefH commented on GitHub (Oct 18, 2024):
@asos-jamiestollery How is it going?
@StefH commented on GitHub (Dec 22, 2024):
https://github.com/WireMock-Net/WireMock.Net/pull/1221