Stubmatic
Stubmatic copied to clipboard
Stubmatic 6
We're currently working on new features in Stubmatic. Your suggestion would help us to lead in the correct direction.
Targeted major features
- Single handler. We were previously using 3 different handlers to feed information to the dynamic response:
<% url.1 %>,[[dumpspath:file1,file2]],{{ TODAY }}. Now we'll be using a single handler:{{ include("file1", "file2") }}. [ Done ] - Record and Play. Now you'll be able to record the response of different servers and serve the same response without connecting to that server again. It also records the request-response mapping to reduce your work. [ Done ]
- Dashboard. We want to create a GUI where you can see all the mappings and recordings. So it'll be helpful to manage all the mappings, reset counters, or add the mappings on the fly. We're also targetting to test a mapping from the dashboard. This feature will surely take long time so we'll be launching partial features with the release of stubmatic 6. And will keep adding more features. [Not started yet]
- Request payload matching. Currently only regex support is provided to match and capture request payload. Sometimes regex become difficult to understand. Hence, we're working on xpath, and jsonpath in case of XML, JSON, YAML inputs. [In Progress]
The sequence of the tags in XML payload or the sequence of properties in JSON payload can be changed. So it is difficult to compare them using regex only. In addition of that, regex are beautiful were difficult to understand. Hence, we're planning to introduce more ways to compare the request payload.
- We're creating 2 functions
xpathandjsonpathwhich can be used to select data from request payload and use it to construct response if needed. - We're providing different mechanisms to compare and match request payload
Here are the sample mapping which should describe what we're planning in Request payload matching. feature;
- Compare the whole payload against the given data. You can provide the options to simplify the comparison. Like, ignore namespace or attributes while comparing the payload.
- request:
url: /search?q=*
payload:
type: XML
matchTo: >
<root>
some value
</root>
options:
ignoreAttributes: true
response:
file: response.xml
- Select some portion of request payload using xpath or json path to compare it.
- request:
url: /search?q=*
payload:
type: XML
selector: xmlpath
matchTo: >
<root>
some value
</root>
options:
ignoreAttributes: true
response:
body: response.xml
- You can even just check fo the existance of particular portion instead of one-to-one comparision.
- request:
url: /search?q=*
payload:
type: XML
selector: xmlpath
options:
ignoreAttributes: true
response:
body: response.xml
- Regex can be used to match and selct some part of the regex.
- request:
url: /search?q=*
payload: some regex(select)
response:
body: {{ payload[1] }}
- Regex can be used to compare XML/JSON data as well
- request:
url: /search?q=*
payload:
type: XML
matchTo: >
<root>
<tag>(.*)</tag?
</root>
options:
ignoreAttributes: true
response:
body: {{xpath("", "payload")}} {{ payload[1]}}