From 774650e40971dbd1bf5a538dad80caceb8014a81 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Thu, 30 Nov 2023 09:11:08 +0100 Subject: [PATCH] Add Test integ for big numbers --- integration/tests_ok/assert_json.html | 8 ++++++++ integration/tests_ok/assert_json.hurl | 8 ++++++++ integration/tests_ok/assert_json.json | 2 +- integration/tests_ok/assert_json.py | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/integration/tests_ok/assert_json.html b/integration/tests_ok/assert_json.html index 8f90fe23a..52df72927 100644 --- a/integration/tests_ok/assert_json.html +++ b/integration/tests_ok/assert_json.html @@ -128,4 +128,12 @@ } ] } + +GET http://localhost:8000/assert-json/big-number +HTTP 200 +[Asserts] +jsonpath "$.big_integer" == 1000000000000000000000 +{ + "big_integer": 1000000000000000000000 +} diff --git a/integration/tests_ok/assert_json.hurl b/integration/tests_ok/assert_json.hurl index d347bdda9..6b129bc7b 100644 --- a/integration/tests_ok/assert_json.hurl +++ b/integration/tests_ok/assert_json.hurl @@ -128,3 +128,11 @@ jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: th } ] } + +GET http://localhost:8000/assert-json/big-number +HTTP 200 +[Asserts] +jsonpath "$.big_integer" == 1000000000000000000000 +{ + "big_integer": 1000000000000000000000 +} diff --git a/integration/tests_ok/assert_json.json b/integration/tests_ok/assert_json.json index caec13125..d668c482d 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"}},{"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}}]}}}}]} +{"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}}]}}}},{"request":{"method":"GET","url":"http://localhost:8000/assert-json/big-number"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.big_integer"},"predicate":{"type":"equal","value":1000000000000000000000}}],"body":{"type":"json","value":{"big_integer":1000000000000000000000}}}}]} diff --git a/integration/tests_ok/assert_json.py b/integration/tests_ok/assert_json.py index ae68bc81b..c68fcefa3 100644 --- a/integration/tests_ok/assert_json.py +++ b/integration/tests_ok/assert_json.py @@ -60,3 +60,13 @@ def assert_json_filter(): }""", mimetype="application/json", ) + + +@app.route("/assert-json/big-number") +def assert_json_big_number(): + return Response( + """{ + "big_integer": 1000000000000000000000 +}""", + mimetype="application/json", + )