Can predicate values have wildcards in Mountebank?

1.3k Views Asked by At

I am trying to define a stub:

{
   "predicates":[
      {
         "equals":{
            "method":"GET",
            "path":"/sword/eBISXMLInvoice2.do",
            "query": {
              "action": "index",
              "page": 3 <-- this one!
            }
         }
      }
   ],
   "responses":[
      {
         "is":{
            "statusCode":200,
            "headers":{
               "Content-Type":"application/xml"
            },
            "body":"<doclist><document uuid='101654' type='invoice' date='2018-11-14 13:49:43' /></doclist>"
         }
      }
   ]
}

One of the expected query string parameters (called "page") can have multiple values. How can I define the predicate to handle this?

1

There are 1 best solutions below

0
On BEST ANSWER

My question is actually very easy to answer. According to the docs, the "equals" predicate, will match if any value matches.

Full text:

On occasion you may encounter multi-valued keys. This can be the case with querystrings and HTTP headers that have repeating keys, for example ?key=first&key=second. In those cases, deepEquals will require all the values (in any order) to match. All other predicates will match if any value matches, so an equals predicate will match with the value of second in the example above.

So I can just remove the changeable query string value from the predicate, or I can keep it in there, it doesn't matter.

  {
     "equals":{
        "method":"GET",
        "path":"/sword/eBISXMLInvoice2.do",
        "query": {
          "action": "index"
        }
     }
  }