Comments (4)
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 queryStringParameters
to match on a proper object which is great. I imagine the next logical extension would be doing this for request bodies, whether they be JSON or HTML multi-part.
Something like this for a parsable body.
- The "*" lives-on as a string wildcard.
- Fields can be marked as optional
- Constraints on enum-type fields. Though this may be getting out of scope for a first draft of this.
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
}
}
}
}
from mmock.
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:
{ "A": "THIS FIELD IS CONSISTENT", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }
I would like to be able to specify the body as
{ "A": "A REQUIRED VALUE", "B": * }
from mmock.
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:
{ "A": "THIS FIELD IS CONSISTENT", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }
I would like to be able to specify the body as
{ "A": "A REQUIRED VALUE", "B": * }
@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:
request:
method: GET
path: /
body: >
{ "A": "A REQUIRED VALUE", "B": * }
should match a payload
{ "A": "A REQUIRED VALUE", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }
but won't match
{ "A": "A REQUIRED VALUE",
"B": "THIS FIELD VARIES AND CAN BE IGNORED" }
from mmock.
apparently it counts spaces as well on wildcard matching and ignores the application/json
header to compare the objects.
so currently it supports only full body wildcard and not a partial matching
from mmock.
Related Issues (20)
- Response compression when request contains Accept-Encoding: gzip, deflate
- Parallel execution HOT 3
- `proxyBaseUrl` + `crazy` or `delay` -- doesn't seem to be working HOT 2
- [Feature Request] multiple callbacks
- Feature Request - support parsing of `request.path` HOT 1
- Feature Request - allow request `path` to be a list of paths
- Unable to escape : (colon) in request path HOT 1
- Question: Ordering with partial matches HOT 1
- Question: how can i define multiple values of one query parameter HOT 2
- Return 500 error instead 404 in case config errors HOT 1
- Question: is it possible to work with date/time? HOT 1
- Incorrect platform issue HOT 10
- v3.0.3 disappeared from Docker Hub HOT 1
- Mapping API set incorrect control delay value HOT 3
- Request headers with first character lowercase does not work HOT 1
- seems it doesn't support regular expression in queryStringParameters??? HOT 2
- Cannot extract keys when Content-type header is not set HOT 1
- Body not parsed correctly with Content-Type=application/json;charset=utf-8
- Support relative paths for `file.contents`
- Feature Request: Support Regular Expressions for Field Values in JSON Request Body
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mmock.