Wiremock: Please add Form parameter matching ( Not query parameter matching)

Created on 8 Apr 2016  路  10Comments  路  Source: tomakehurst/wiremock

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!

Feature request

Most helpful comment

Yeah, sometime in the next 100 years. Happy to receive a PR, as ever 馃槉

All 10 comments

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?

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wujimin picture wujimin  路  4Comments

martin-sladecek picture martin-sladecek  路  4Comments

MOUBARAKI picture MOUBARAKI  路  5Comments

neilg picture neilg  路  4Comments

j3t picture j3t  路  5Comments