1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
# Make reference to prior request response data via json path.
#
tests:
- name: post some json
url: /posterchild
request_headers:
content-type: application/json
data: '{"a": 1, "b": 2, "link": "/v2"}'
method: POST
response_json_paths:
a: 1
b: 2
link: "/v2"
response_headers:
location: $SCHEME://$NETLOC/posterchild
- name: post some more json
url: $RESPONSE["link"]
request_headers:
content-type: application/json
method: POST
data:
a: $RESPONSE['a']
c: $RESPONSE['link']
d:
z: $RESPONSE['b']
response_json_paths:
a: $RESPONSE["a"]
c: /v2
d:
z: $RESPONSE['b']
response_headers:
x-gabbi-url: $SCHEME://$NETLOC/v2
- name: post even more json
url: $RESPONSE['c']
request_headers:
content-type: application/json
method: POST
data: |
{"a": "$RESPONSE['a']",
"c": "$RESPONSE['c']"}
response_strings:
- '"a": "$RESPONSE[''a'']"'
- '"c": "/v2"'
response_headers:
location: $SCHEME://$NETLOC$RESPONSE['c']
x-gabbi-url: $SCHEME://$NETLOC/v2
content-type: $HEADERS['content-type']
- name: post even more json quote different
url: $RESPONSE["c"]
request_headers:
content-type: application/json
method: POST
data: |
{"a": $RESPONSE["a"],
"c": "$RESPONSE["c"]"}
response_strings:
- '"a": $RESPONSE["a"]'
- '"c": "/v2"'
response_headers:
location: $SCHEME://$NETLOC$RESPONSE['c']
x-gabbi-url: $SCHEME://$NETLOC/v2
content-type: $HEADERS['content-type']
- name: use raw json from response
POST: $LAST_URL
request_headers:
content-type: application/json
# the value of '$' here should be {"c": "/v2", "a": 1}
data: $RESPONSE['$']
response_json_paths:
$.c: /v2
$.a: 1
- name: post a raw int as json
POST: /
request_headers:
content-type: application/json
data: 1
response_json_paths:
$: 1
- name: repost that raw int
POST: /
request_headers:
content-type: application/json
data: $RESPONSE['$']
response_json_paths:
$: 1
- name: backref json fail start
url: /
method: POST
data: ''
- name: backref json fail end
xfail: true
url: $RESPONSE['url']
- name: get a historical response
GET: /$HISTORY['post some json'].$RESPONSE['a']
response_headers:
x-gabbi-url: $SCHEME://$NETLOC/1
- name: get a historical response via jsonpath
GET: /$HISTORY['post some json'].$RESPONSE['$.b']
response_headers:
x-gabbi-url: $SCHEME://$NETLOC/2
|