Hi,
I am using WireMock 2.0.10-beta version. I didn't see any API for Form parameter matching. Not query parameter matching. I used withQueryParam for form parameter matching and got error.
API Proposal
withFormParam("p1", equalTo("v1"));
OR
withRequestParam("p1", equalTo("v1")); // Work for both Query params & Form params
Thank you!
I like the first one. I'm happy to add it to the to-do list, but if you want to speed things up, perhaps you could create a PR?
I think withRequestParam is better. Like HttpServletRequest. It has only one method getParameter for both query param and form param. Thank you!
I'll give it some thought. I tend to prefer being explicit as to which you're expecting, but I guess there might be cases where you're using a method of ANY and therefore don't know in which form the parameters will arrive.
It looks like @iamtommo made an attempt at this in #463
How is it going @tomakehurst ? Are you planning to tackle this problem? :)
Yeah, sometime in the next 100 years. Happy to receive a PR, as ever 馃槉
Is there another way to match the FORM parameters with regular expressions if not an explicit API to read those?
Just use http://www.mock-server.com/mock_server/creating_expectations.html#button_match_request_by_form_submission_body
I tried extendind Wiremock for form params, but together with https://github.com/tomakehurst/wiremock/issues/870 it is in vain
got the purpose fulfilled by withRequestBody() for now.
Thanks @intracer for the reference. It looks good. Bookmarked for the future!
@tomakehurst I'm really keen to have this. What would be required to implement it? From what I can tell we just need to declare a new implementation of StringValuePattern in StringValuePatternJsonDeserializer like:
.put("matchesFormParam", MatchesFormParamPattern.class)
and then, for Java clients, add some convenience methods to Wiremock.java like
public static StringValuePattern matchingFormParam(String field, String value) {
return matchingFormParam(value, equalTo(value));
}
public static StringValuePattern matchingFormParam(String value, StringValuePattern valuePattern) {
return new MatchesFormParamPattern(value, valuePattern);
}
Is this all that is required?
Most helpful comment
Yeah, sometime in the next 100 years. Happy to receive a PR, as ever 馃槉