-
Notifications
You must be signed in to change notification settings - Fork 291
Open
Description
Hello!
I'm can't understand whats going on...
But when my requests has array ["REPAIR", "NEED_ADVICE"]
- predicate is not matches when I use jsonpath
I'm try with different variants:
["REPAIR", "NEEDADVICE"]
not working
["ONE", "ONE_TWO"]
is working
["ONE", "TWO", "ONE_TWO"]
not working
["ONEONEONEONE", "TWOTWOTWOTWO"]
is working
["ONE", "TWO", "THREE"]
not working
In my steps to reproduce I'm specially leave jsonpath selector as $
- in my real life this is field from body, but for example this is don't matter :)
Expected behaviour
Predicate is matches, I have response from mountebank
...
Actual behaviour
Predicate is not matches, I have default response
...
Steps to reproduce
$ docker run --rm -p 2525:2525 -p 4545:4545 -p 5555:5555 bbyars/mountebank:2.9.1 start --debug --loglevel debug
$ curl -i -X POST -H 'Content-Type: application/json' http://localhost:2525/imposters --data '{ "port": 4545, "protocol": "http", "recordRequests": true, "defaultResponse": { "statusCode": 400, "body": "No suitable mock", "headers": {} }, "stubs": [{ "predicates": [{ "deepEquals": { "body": { "tags": ["REPAIR", "NEED_ADVICE"] } }, "jsonpath": { "selector": "$" } }], "responses": [{ "is": { "body": { "success": true }, "statusCode": 200 } }] }] }'
3$ curl -i http://localhost:4545/ --data '{"tags": ["REPAIR", "NEED_ADVICE"]}'
...
Software versions used
OS : docker
mountebank : 2.9.1
node.js :
(only if installed via npm)
Installation method :
(npm, zip, tar, pkg, deb, rpm)
Log contents in mb.log when running mb --loglevel debug
info: [mb:2525] mountebank v2.9.1 now taking orders - point your browser to http://localhost:2525/ for help
debug: [mb:2525] config: {"options":{"debug":true,"port":2525,"noParse":false,"no-parse":false,"formatter":"mountebank-formatters","pidfile":"mb.pid","allowInjection":false,"allow-injection":false,"localOnly":false,"local-only":false,"ipWhitelist":["*"],"ip-whitelist":"*","mock":false,"protofile":"protocols.json","origin":false,"apikey":null,"log":{"level":"debug","transports":{"console":{"colorize":true,"format":"%level: %message"},"file":{"path":"mb.log","format":"json"}}}},"process":{"nodeVersion":"v18.17.1","architecture":"arm64","platform":"linux"}}
info: [mb:2525] POST /imposters
debug: [mb:2525] ::ffff:172.17.0.1:43084 => {"port":4545,"protocol":"http","recordRequests":true,"defaultResponse":{"statusCode":400,"body":"No suitable mock","headers":{}},"stubs":[{"predicates":[{"deepEquals":{"body":{"tags":["REPAIR","NEED_ADVICE"]}},"jsonpath":{"selector":"$"}}],"responses":[{"is":{"body":{"success":true},"statusCode":200}}]}]}
info: [http:4545] Open for business...
debug: [http:4545] ::ffff:172.17.0.1:58062 ESTABLISHED
info: [http:4545] ::ffff:172.17.0.1:58062 => POST /
debug: [http:4545] ::ffff:172.17.0.1:58062 => {"requestFrom":"::ffff:172.17.0.1:58062","method":"POST","path":"/","query":{},"headers":{"Host":"localhost:4545","User-Agent":"curl/8.7.1","Accept":"*/*","Content-Length":"35","Content-Type":"application/x-www-form-urlencoded"},"body":"{\"tags\": [\"REPAIR\", \"NEED_ADVICE\"]}","ip":"::ffff:172.17.0.1","form":{"{\"tags\": [\"REPAIR\", \"NEED_ADVICE\"]}":""}}
info: [http:4545] no predicate match, using default response
debug: [http:4545] generating response from {"is":{}}
debug: [http:4545] ::ffff:172.17.0.1:58062 <= {"statusCode":400,"headers":{"Connection":"close"},"body":"No suitable mock","_mode":"text"}
debug: [http:4545] ::ffff:172.17.0.1:58062 CLOSED
After one request (like in steps to reproduce) I have this information in imposter
$ curl http://localhost:2525/imposters/4545
{
"protocol": "http",
"port": 4545,
"defaultResponse": {
"statusCode": 400,
"body": "No suitable mock",
"headers": {}
},
"numberOfRequests": 1,
"recordRequests": true,
"requests": [
{
"requestFrom": "::ffff:172.17.0.1:35664",
"method": "POST",
"path": "/",
"query": {},
"headers": {
"Host": "localhost:4545",
"User-Agent": "curl/8.7.1",
"Accept": "*/*",
"Content-Length": "35",
"Content-Type": "application/x-www-form-urlencoded"
},
"body": "{\"tags\": [\"REPAIR\", \"NEED_ADVICE\"]}",
"ip": "::ffff:172.17.0.1",
"form": {
"{\"tags\": [\"REPAIR\", \"NEED_ADVICE\"]}": ""
},
"timestamp": "2024-10-28T18:00:10.378Z"
}
],
"stubs": [
{
"predicates": [
{
"deepEquals": {
"body": {
"tags": [
"REPAIR",
"NEED_ADVICE"
]
}
},
"jsonpath": {
"selector": "$"
}
}
],
"responses": [
{
"is": {
"body": {
"success": true
},
"statusCode": 200
}
}
],
"_links": {
"self": {
"href": "http://localhost:2525/imposters/4545/stubs/0"
}
}
}
],
"_links": {
"self": {
"href": "http://localhost:2525/imposters/4545"
},
"stubs": {
"href": "http://localhost:2525/imposters/4545/stubs"
}
}
}
Metadata
Metadata
Assignees
Labels
No labels