0

I tried their documentation, but it's very "basic", so hope somebody here can spot my issue? I got 2 predicates, one with the wrong user, one with the right user. The user's base64 is sent via post-body, but it seems the contains of Mountebank is simply ignoring it and choosing a predicate with another contains value... why is that?

my request is with dX...2g=:

"body":"{\"auth\":\"dXNlcjpmYWxzY2g=\"}"

but Mountebank matches a predicate with dX...Gln:

using predicate match: [{
   "equals":{"method":"POST","path":"/new"},
   "contains":{"body":"{\"auth\":\"dXNlcjpyaWNodGln\""}
}]

The contains doesn't match, and still it's using that predicate, even though my stubs do contain a matching predicate, but it is not used:

{
  "path": "/new",
  "predicates": [{
    "equals": {
      "method": "POST",
      "path": "/new"
    },
    "contains": {
      "body": "{\"auth\":\"dXNlcjpyaWNodGln\""
    }
  }],
  "responses": [{
    "is": {
      "statusCode": 200,
      "body": {}
      }
    }
  }]
}
,
{
  "path": "/new",
  "predicates": [{
    "equals": {
      "method": "POST",
      "path": "/new"
    },
    "contains": {
      "body": "{\"auth\":\"dXNlcjpmYWxzY2g=\""
    }
  }],
  "responses": [{
    "is": {
      "statusCode": 401,
      "body": {}
      }
    }
  }]
}

Is my syntax wrong? It's matching the first predicate, even though it does not contain dXNlcjpmYWxzY2g= It does work using equals, I'm just curious why contains isn't.

MushyPeas
  • 2,469
  • 2
  • 31
  • 48

1 Answers1

0

The trick seemed to be use and, which is odd, but the solution would be:

"predicates": [{
  "and": [
    { "equals": { "method": "POST", "path": "/new" }},
    { "contains": { "body": "{\"auth\":\"dXNlcjpyaWNodGln\"" }}
  ]
}],
MushyPeas
  • 2,469
  • 2
  • 31
  • 48