diff --git a/integration/tests_ok/assert_json.html b/integration/tests_ok/assert_json.html index e93ccdceb..8f90fe23a 100644 --- a/integration/tests_ok/assert_json.html +++ b/integration/tests_ok/assert_json.html @@ -105,9 +105,27 @@ jsonpath "$.[?(@.id == 1)].name" nth 0 == "Bob" jsonpath "$[?(@.id == 1)].name" nth 0 == "Bob" - GET http://localhost:8000/assert-json/filter HTTP 200 [Asserts] jsonpath "$.fruit[?(@.price.US==200)].name" nth 0 == "grape" +jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: the first fruit is return by jsonpath.com +{ + "fruit": [ + { + "name": "apple", + "price": { + "US": 100, + "UN": 110 + } + }, + { + "name": "grape", + "price": { + "US": 200, + "UN": 150 + } + } + ] +} diff --git a/integration/tests_ok/assert_json.hurl b/integration/tests_ok/assert_json.hurl index 49e6b72a5..d347bdda9 100644 --- a/integration/tests_ok/assert_json.hurl +++ b/integration/tests_ok/assert_json.hurl @@ -105,8 +105,26 @@ jsonpath "$[0].name" == "Bob" jsonpath "$.[?(@.id == 1)].name" nth 0 == "Bob" jsonpath "$[?(@.id == 1)].name" nth 0 == "Bob" - GET http://localhost:8000/assert-json/filter HTTP 200 [Asserts] jsonpath "$.fruit[?(@.price.US==200)].name" nth 0 == "grape" +jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: the first fruit is return by jsonpath.com +{ + "fruit": [ + { + "name": "apple", + "price": { + "US": 100, + "UN": 110 + } + }, + { + "name": "grape", + "price": { + "US": 200, + "UN": 150 + } + } + ] +} diff --git a/integration/tests_ok/assert_json.json b/integration/tests_ok/assert_json.json index 34b6d9bd1..caec13125 100644 --- a/integration/tests_ok/assert_json.json +++ b/integration/tests_ok/assert_json.json @@ -1 +1 @@ -{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/assert-json","options":[{"name":"variable","value":"one=1"},{"name":"variable","value":"two=2"},{"name":"variable","value":"three=3"},{"name":"variable","value":"four=4"},{"name":"variable","value":"five=5"},{"name":"variable","value":"foo=abc"},{"name":"insecure","value":false}]},"response":{"status":200,"captures":[{"name":"count","query":{"type":"jsonpath","expr":"$.count"}}],"asserts":[{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":5}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":5.0}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":"five"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"not-equal","value":4}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"not-equal","value":"four"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"not":true,"type":"equal","value":4}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":1}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":"one"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":1.0}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"equal","value":false}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"not-equal","value":null}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"isBoolean"}},{"query":{"type":"jsonpath","expr":"$.errors"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.failures"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":1}},{"query":{"type":"jsonpath","expr":"$.failures"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.warnings"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":0}},{"query":{"type":"jsonpath","expr":"$.warnings"},"predicate":{"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.toto"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.failures"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.warnings"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.errors[0].id"},"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[0].id"},"predicate":{"type":"isString"}},{"query":{"type":"jsonpath","expr":"$.errors[0]['id']"},"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[*].id"},"predicate":{"type":"include","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[0,1].id"},"predicate":{"type":"include","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[:2].id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors[0:].id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors[?(@.id)].id"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[?(@.id=='error1')].id"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.failures[*].id"},"predicate":{"type":"include","value":"failure1"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"equal","value":1.5}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less-or-equal","value":2.0}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less","value":2}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less","value":"two"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"not":true,"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.nullable"},"predicate":{"type":"equal","value":null}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"equal","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"greater","value":"te"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"less","value":"testabc"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"less-or-equal","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"greater","value":"{{foo}}"}},{"query":{"type":"jsonpath","expr":"$.profile-id"},"predicate":{"type":"equal","value":"123abc"}},{"query":{"type":"jsonpath","expr":"$['profile-id']"},"predicate":{"type":"equal","value":"123abc"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"not":true,"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.empty"},"predicate":{"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.*"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":10}},{"query":{"type":"jsonpath","expr":"$.errors..*"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":4}},{"query":{"type":"jsonpath","expr":"$..id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":3}}],"body":{"type":"json","value":{"count":5,"success":false,"errors":[{"id":"error1"},{"id":"error2"}],"failures":[{"id":"failure1"}],"warnings":[],"duration":1.5,"tags":["test"],"nullable":null,"profile-id":"123abc","empty":{}}}}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/index"},"response":{"status":200,"captures":[{"name":"index","query":{"type":"body"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.errors[{{index}}].id"},"predicate":{"type":"equal","value":"error2"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"type":"include","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":"prod"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":null}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/list"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.[0].name"},"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$[0].name"},"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$.[?(@.id == 1)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$[?(@.id == 1)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"Bob"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/filter"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.fruit[?(@.price.US==200)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"grape"}}]}}]} +{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/assert-json","options":[{"name":"variable","value":"one=1"},{"name":"variable","value":"two=2"},{"name":"variable","value":"three=3"},{"name":"variable","value":"four=4"},{"name":"variable","value":"five=5"},{"name":"variable","value":"foo=abc"},{"name":"insecure","value":false}]},"response":{"status":200,"captures":[{"name":"count","query":{"type":"jsonpath","expr":"$.count"}}],"asserts":[{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":5}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":5.0}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"equal","value":"five"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"not-equal","value":4}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"not-equal","value":"four"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"not":true,"type":"equal","value":4}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":1}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":"one"}},{"query":{"type":"jsonpath","expr":"$.count"},"predicate":{"type":"greater","value":1.0}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"equal","value":false}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"not-equal","value":null}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.success"},"predicate":{"type":"isBoolean"}},{"query":{"type":"jsonpath","expr":"$.errors"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.failures"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":1}},{"query":{"type":"jsonpath","expr":"$.failures"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.warnings"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":0}},{"query":{"type":"jsonpath","expr":"$.warnings"},"predicate":{"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.toto"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.failures"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.warnings"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"type":"isCollection"}},{"query":{"type":"jsonpath","expr":"$.errors[0].id"},"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[0].id"},"predicate":{"type":"isString"}},{"query":{"type":"jsonpath","expr":"$.errors[0]['id']"},"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[*].id"},"predicate":{"type":"include","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[0,1].id"},"predicate":{"type":"include","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[:2].id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors[0:].id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.errors[?(@.id)].id"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.errors[?(@.id=='error1')].id"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"error1"}},{"query":{"type":"jsonpath","expr":"$.failures[*].id"},"predicate":{"type":"include","value":"failure1"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"equal","value":1.5}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less-or-equal","value":2.0}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less","value":2}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"less","value":"two"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.duration"},"predicate":{"not":true,"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.nullable"},"predicate":{"type":"equal","value":null}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"equal","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"greater","value":"te"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"less","value":"testabc"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"less-or-equal","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags[0]"},"predicate":{"type":"greater","value":"{{foo}}"}},{"query":{"type":"jsonpath","expr":"$.profile-id"},"predicate":{"type":"equal","value":"123abc"}},{"query":{"type":"jsonpath","expr":"$['profile-id']"},"predicate":{"type":"equal","value":"123abc"}},{"query":{"type":"jsonpath","expr":"$.errors[0]"},"predicate":{"not":true,"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.empty"},"predicate":{"type":"isEmpty"}},{"query":{"type":"jsonpath","expr":"$.*"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":10}},{"query":{"type":"jsonpath","expr":"$.errors..*"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":4}},{"query":{"type":"jsonpath","expr":"$..id"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":3}}],"body":{"type":"json","value":{"count":5,"success":false,"errors":[{"id":"error1"},{"id":"error2"}],"failures":[{"id":"failure1"}],"warnings":[],"duration":1.5,"tags":["test"],"nullable":null,"profile-id":"123abc","empty":{}}}}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/index"},"response":{"status":200,"captures":[{"name":"index","query":{"type":"body"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.errors[{{index}}].id"},"predicate":{"type":"equal","value":"error2"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"type":"include","value":"test"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":"prod"}},{"query":{"type":"jsonpath","expr":"$.tags"},"predicate":{"not":true,"type":"include","value":null}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/list"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":2}},{"query":{"type":"jsonpath","expr":"$.[0].name"},"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$[0].name"},"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$.[?(@.id == 1)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$[?(@.id == 1)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"Bob"}}]}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/filter"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.fruit[?(@.price.US==200)].name"},"filters":[{"type":"nth","n":0}],"predicate":{"type":"equal","value":"grape"}},{"query":{"type":"jsonpath","expr":"$.fruit.[?(@.US == 100)]"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":0}}],"body":{"type":"json","value":{"fruit":[{"name":"apple","price":{"US":100,"UN":110}},{"name":"grape","price":{"US":200,"UN":150}}]}}}}]}