Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern * dont work in request body strings #96

Closed
Carsak opened this issue Oct 27, 2019 · 2 comments
Closed

Pattern * dont work in request body strings #96

Carsak opened this issue Oct 27, 2019 · 2 comments

Comments

@Carsak
Copy link

Carsak commented Oct 27, 2019

Actual Problem:
I have simple config for POST

description: "Create Order POST"
request:
  method: POST
  path: /order/create/
  body: '{"email": "alma@alma.*", "product": "choco-cookies", "quantity" : 3}'
response:
  headers:
    Content-Type:
      - application/json
  statusCode: 200
  body: '{"status": "ok"}'

with pattern "alma@alma.*" in request body
but when I send request

{
    "scheme": "http",
    "host": "localhost",
    "port": "8083",
    "method": "POST",
    "path": "/order/create/",
    "queryStringParameters": {},
    "fragment": "",
    "headers": {
        "Accept-Encoding": [
            "gzip,deflate"
        ],
        "Connection": [
            "Keep-Alive"
        ],
        "Content-Length": [
            "71"
        ],
        "Content-Type": [
            "application/json"
        ],
        "User-Agent": [
            "Apache-HttpClient/4.5.8 (Java/11.0.3)"
        ]
    },
    "cookies": {},
    "body": "{\"email\" : \"alma@alma.kz\", \"product\" : \"choco-cookies\", \"quantity\" : 3}"
}
Response

, mmock says Error

"uri": "OrderCreatePositive.yaml",
            "reason": "Body not match. Actual: {\"email\" : \"alma@alma.kz\", \"product\" : \"choco-cookies\", \"quantity\" : 3}, Expected: {\"email\": \"alma@alma.*\", \"product\": \"choco-cookies\", \"quantity\" : 3}"

Expected:
Even email send like alma@alma.kz or alma@alma.ru or alma.alma@com the request body must match

@Carsak Carsak changed the title Pattern * dont work in json strings Pattern * dont work in request body strings Oct 27, 2019
@jmartin82
Copy link
Owner

Hi!

The glob pattern match is using the whole body as input not only the field value, that makes it a bit picky and the previous and the following strings to glob expression should match perfectly.

This is the correct payload with the spaces ajusted.

curl -X POST \ http://192.168.0.18:8083/order/create/ \ -H 'content-type: application/json' \ -d '{"email": "alma@alma.kz", "product": "choco-cookies", "quantity" : 3}'

@Carsak
Copy link
Author

Carsak commented Nov 1, 2019

@jmartin82
Thank you
issue maybe closed

@Carsak Carsak closed this as completed Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants