-
Notifications
You must be signed in to change notification settings - Fork 83
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
Partial match and unordered match of request body #112
Comments
I am running into this exact same issue. I have a body where I want to match on one parameter, but the others will vary by test case and aren't relevant to the data I'm submitting. Example:
I would like to be able to specify the body as
|
@dkoontz I had a similar issue until I figured that body payload must match the text exactly, the wildcard just allow anything in that position of the string. check if your submitted payload matches the break lines and spaces in your request config. I had a similar issue because my payload was sent as compacted JSON (one line, no spaces) and the config had break lines. For example:
should match a payload
but won't match
|
I also got stuck with this issue and was surprised to find it's doing string matching on a JSON body. Request matching already has Something like this for a parsable body.
request:
method: POST
path: /auth/sessions
bodyParams:
username: "*"
password: "*"
remember_me:
one_of: ["true", "false"]
another_field:
optional: true Same thing with JSON config: {
"request": {
"method": "POST",
"path": "/auth/sessions",
"bodyParams": {
"username": "*",
"password": "*",
"remember_me": {
"one_of": [
"true",
"false"
]
},
"another_field": {
"optional": true
}
}
}
} |
apparently it counts spaces as well on wildcard matching and ignores the |
I want to match bodies with at least a set of specific key-value pairs in either a JSON-encoded or www-form-urlencoded body.
This is a probably insecure example but:
if
Content-Type
isapplication/json
and the body is{ "username": "*", "password": "*" }
then i respond with 200. Any valid json string specifying the username and password would ideally match that, but instead it has to match exactly, spaces and all.So the order of the fields shouldn't matter either e.g.:
{ "password": "*", "username": "*" }
should be 200 too.So then I could then match on just the username too for example, and say password required if there's at least some valid string with a username.
So I could match
{ "username": "*" }
or{"username" :"*"}
or any other valid json string to return something likepassword required
.And a similar behaviour for
application/x-www-form-urlencoded
- the order shouldn't matter in the string as long as the specified values match.Is that kind of thing currently possible? I can't see an easy way to do it when body is just a string match.
The text was updated successfully, but these errors were encountered: