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

Stubmatic 6 #14

Open
amitguptagwl opened this issue Oct 24, 2019 · 1 comment
Open

Stubmatic 6 #14

amitguptagwl opened this issue Oct 24, 2019 · 1 comment
Labels
discussion discussion on the design or implementation approach

Comments

@amitguptagwl
Copy link
Member

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 amitguptagwl added the discussion discussion on the design or implementation approach label Oct 24, 2019
@amitguptagwl
Copy link
Member Author

amitguptagwl commented Oct 24, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion discussion on the design or implementation approach
Projects
None yet
Development

No branches or pull requests

1 participant