protean icon indicating copy to clipboard operation
protean copied to clipboard

Test should extract values from body as it does for headers

Open colin-lamed opened this issue 10 years ago • 5 comments

Since we have removed the in-line response body, we cannot extract data from the response. This used to work in the same way as headers. However, we need something more flexible that the header parsing - since the values may be embedded in dynamic content.

colin-lamed avatar Jun 16 '15 15:06 colin-lamed

on branch: extract_response_vars, have added the ability to configure a json-path to extract data:

:rsp {
  :200 {
    :extract-vars {
      "$[0].id" "${usermessageId}"
     }

This should also support x-path for application/xml etc.

This fixes endpoint dependencies when calculating path to visit the endpoints.

Not particularly attached to the config naming - suggestions welcome.

colin-lamed avatar Jun 16 '15 15:06 colin-lamed

better naming would be something like :body-data? A little less imperative... However, it may be possible to generate a json-path by analysing a body example with placeholders... Something like: rsp body example: [{"id": "${ph}", ...},...] would generate "$[0].id" (i.e. id of first result)

colin-lamed avatar Jun 16 '15 16:06 colin-lamed

I kinda get it... but I don't understand 'This fixes endpoint dependencies when calculating path to visit the endpoints.'. Then again it is too early in the morning :-) Did you mean in reference to auto testing ?

rossajmcd avatar Jun 17 '15 06:06 rossajmcd

Yes, auto-tests. It would give us a mechanism to to define the source of a variable (currently only header response supported), which the endpoint path calculation will subsequently use. In example above, any endpoint that requires userMessageId as input, must be called after the above endpoint which returns the userMessageId in the response body.

colin-lamed avatar Jun 17 '15 08:06 colin-lamed

I kinda get it but I'd like to work through it with you.. can't devote enough capacity to it at the moment... lets do it over curry ? :+1:

rossajmcd avatar Jun 23 '15 19:06 rossajmcd