Stubmatic icon indicating copy to clipboard operation
Stubmatic copied to clipboard

Stubmatic 6

Open amitguptagwl opened this issue 6 years ago • 1 comments

We're currently working on new features in Stubmatic. Your suggestion would help us to lead in the correct direction.

Targeted major features

  1. 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 ]
  2. 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 ]
  3. 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]
  4. 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]

amitguptagwl avatar Oct 24 '19 00:10 amitguptagwl

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.

  1. We're creating 2 functions xpath and jsonpath which can be used to select data from request payload and use it to construct response if needed.
  2. 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;

  1. 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
  1. 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
  1. 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
  1. 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] }}
  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]}}

amitguptagwl avatar Oct 24 '19 02:10 amitguptagwl