Skip to content

Commit

Permalink
Update hurlfmt filter export test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishajr committed Jan 23, 2025
1 parent d658053 commit 2b88b56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion integration/hurlfmt/tests_export/filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<span class="line"><span class="section-header">[Captures]</span></span>
<span class="line"><span class="string">count</span>: <span class="query-type">jsonpath</span> <span class="string">"$.books"</span> <span class="filter-type">count</span></span>
<span class="line"><span class="section-header">[Asserts]</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.data"</span> <span class="filter-type">base64Decode</span> <span class="predicate-type">==</span> hex,<span class="hex">48656c6c6f</span>;</span> <span class="comment"># base64Decode</span>
<span class="line"><span class="query-type">bytes</span> <span class="filter-type">base64Encode</span> <span class="predicate-type">==</span> <span class="string">"SGVsbG8="</span></span> <span class="comment"># base64Encode</span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.books"</span> <span class="filter-type">count</span> <span class="predicate-type">==</span> <span class="number">12</span></span> <span class="comment"># count</span>
<span class="line"><span class="query-type">certificate</span> <span class="string">"Expire-Date"</span> <span class="filter-type">daysAfterNow</span> <span class="predicate-type">&gt;</span> <span class="number">15</span></span> <span class="comment"># daysAfterNow</span>
<span class="line"><span class="query-type">certificate</span> <span class="string">"Start-Date"</span> <span class="filter-type">daysBeforeNow</span> <span class="predicate-type">&lt;</span> <span class="number">100</span></span> <span class="comment"># daysBeforeNow</span>
Expand All @@ -22,4 +24,4 @@
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.encoded_url"</span> <span class="filter-type">urlDecode</span> <span class="predicate-type">==</span> <span class="string">"https://mozilla.org/?x=шеллы"</span></span> <span class="comment"># urlDecode</span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.url"</span> <span class="filter-type">urlEncode</span> <span class="predicate-type">==</span> <span class="string">"https%3A//mozilla.org/%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"</span></span> <span class="comment"># urlEncode</span>
<span class="line"><span class="query-type">bytes</span> <span class="filter-type">decode</span> <span class="string">"iso-8859-1"</span> <span class="filter-type">xpath</span> <span class="string">"string(//p)"</span> <span class="predicate-type">==</span> <span class="string">"Hello"</span></span> <span class="comment"># xpath</span>
</span></span></code></pre>
</span></span></code></pre>
2 changes: 2 additions & 0 deletions integration/hurlfmt/tests_export/filter.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ HTTP 200
[Captures]
count: jsonpath "$.books" count
[Asserts]
jsonpath "$.data" base64Decode == hex,48656c6c6f; # base64Decode
bytes base64Encode == "SGVsbG8=" # base64Encode
jsonpath "$.books" count == 12 # count
certificate "Expire-Date" daysAfterNow > 15 # daysAfterNow
certificate "Start-Date" daysBeforeNow < 100 # daysBeforeNow
Expand Down
2 changes: 1 addition & 1 deletion integration/hurlfmt/tests_export/filter.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/dummy"},"response":{"status":200,"captures":[{"name":"count","query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"count"}]}],"asserts":[{"query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":12}},{"query":{"type":"certificate","expr":"Expire-Date"},"filters":[{"type":"daysAfterNow"}],"predicate":{"type":"greater","value":15}},{"query":{"type":"certificate","expr":"Start-Date"},"filters":[{"type":"daysBeforeNow"}],"predicate":{"type":"less","value":100}},{"query":{"type":"bytes"},"filters":[{"type":"decode","encoding":"iso-8859-1"}],"predicate":{"type":"equal","value":"café"}},{"query":{"type":"cookie","expr":"LSID[Expires]"},"filters":[{"type":"format","fmt":"%a, %d %b %Y %H:%M:%S"}],"predicate":{"type":"equal","value":"Wed, 13 Jan 2021 22:23:01"}},{"query":{"type":"jsonpath","expr":"$.text"},"filters":[{"type":"htmlEscape"}],"predicate":{"type":"equal","value":"a &gt; b"}},{"query":{"type":"jsonpath","expr":"$.escaped_html[1]"},"filters":[{"type":"htmlUnescape"}],"predicate":{"type":"equal","value":"<p>Hello</p>"}},{"query":{"type":"variable","name":"books"},"filters":[{"type":"jsonpath","expr":"$[0].name"}],"predicate":{"type":"equal","value":"Dune"}},{"query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"nth","n":2}],"predicate":{"type":"equal","value":"Children of Dune"}},{"query":{"type":"body"},"filters":[{"type":"regex","expr":{"type":"regex","value":"Hello ([0-9]+)!"}}],"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$.ips"},"filters":[{"type":"replace","old_value":", ","new_value":"|"}],"predicate":{"type":"equal","value":"192.168.2.1|10.0.0.20|10.0.0.10"}},{"query":{"type":"jsonpath","expr":"$.ips"},"filters":[{"type":"split","sep":", "},{"type":"count"}],"predicate":{"type":"equal","value":3}},{"query":{"type":"header","name":"Expires"},"filters":[{"type":"toDate","fmt":"%a, %d %b %Y %H:%M:%S GMT"},{"type":"daysBeforeNow"}],"predicate":{"type":"greater","value":1000}},{"query":{"type":"jsonpath","expr":"$.pi"},"filters":[{"type":"toFloat"}],"predicate":{"type":"equal","value":3.14}},{"query":{"type":"jsonpath","expr":"$.id"},"filters":[{"type":"toInt"}],"predicate":{"type":"equal","value":123}},{"query":{"type":"jsonpath","expr":"$.encoded_url"},"filters":[{"type":"urlDecode"}],"predicate":{"type":"equal","value":"https://mozilla.org/?x=шеллы"}},{"query":{"type":"jsonpath","expr":"$.url"},"filters":[{"type":"urlEncode"}],"predicate":{"type":"equal","value":"https%3A//mozilla.org/%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"}},{"query":{"type":"bytes"},"filters":[{"type":"decode","encoding":"iso-8859-1"},{"type":"xpath","expr":"string(//p)"}],"predicate":{"type":"equal","value":"Hello"}}]}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/dummy"},"response":{"status":200,"captures":[{"name":"count","query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"count"}]}],"asserts":[{"query":{"type":"jsonpath","expr":"$.data"},"filters":[{"type":"base64Decode"}],"predicate":{"type":"equal","value":"SGVsbG8=","encoding":"base64"}},{"query":{"type":"bytes"},"filters":[{"type":"base64Encode"}],"predicate":{"type":"equal","value":"SGVsbG8="}},{"query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":12}},{"query":{"type":"certificate","expr":"Expire-Date"},"filters":[{"type":"daysAfterNow"}],"predicate":{"type":"greater","value":15}},{"query":{"type":"certificate","expr":"Start-Date"},"filters":[{"type":"daysBeforeNow"}],"predicate":{"type":"less","value":100}},{"query":{"type":"bytes"},"filters":[{"type":"decode","encoding":"iso-8859-1"}],"predicate":{"type":"equal","value":"café"}},{"query":{"type":"cookie","expr":"LSID[Expires]"},"filters":[{"type":"format","fmt":"%a, %d %b %Y %H:%M:%S"}],"predicate":{"type":"equal","value":"Wed, 13 Jan 2021 22:23:01"}},{"query":{"type":"jsonpath","expr":"$.text"},"filters":[{"type":"htmlEscape"}],"predicate":{"type":"equal","value":"a &gt; b"}},{"query":{"type":"jsonpath","expr":"$.escaped_html[1]"},"filters":[{"type":"htmlUnescape"}],"predicate":{"type":"equal","value":"<p>Hello</p>"}},{"query":{"type":"variable","name":"books"},"filters":[{"type":"jsonpath","expr":"$[0].name"}],"predicate":{"type":"equal","value":"Dune"}},{"query":{"type":"jsonpath","expr":"$.books"},"filters":[{"type":"nth","n":2}],"predicate":{"type":"equal","value":"Children of Dune"}},{"query":{"type":"body"},"filters":[{"type":"regex","expr":{"type":"regex","value":"Hello ([0-9]+)!"}}],"predicate":{"type":"equal","value":"Bob"}},{"query":{"type":"jsonpath","expr":"$.ips"},"filters":[{"type":"replace","old_value":", ","new_value":"|"}],"predicate":{"type":"equal","value":"192.168.2.1|10.0.0.20|10.0.0.10"}},{"query":{"type":"jsonpath","expr":"$.ips"},"filters":[{"type":"split","sep":", "},{"type":"count"}],"predicate":{"type":"equal","value":3}},{"query":{"type":"header","name":"Expires"},"filters":[{"type":"toDate","fmt":"%a, %d %b %Y %H:%M:%S GMT"},{"type":"daysBeforeNow"}],"predicate":{"type":"greater","value":1000}},{"query":{"type":"jsonpath","expr":"$.pi"},"filters":[{"type":"toFloat"}],"predicate":{"type":"equal","value":3.14}},{"query":{"type":"jsonpath","expr":"$.id"},"filters":[{"type":"toInt"}],"predicate":{"type":"equal","value":123}},{"query":{"type":"jsonpath","expr":"$.encoded_url"},"filters":[{"type":"urlDecode"}],"predicate":{"type":"equal","value":"https://mozilla.org/?x=шеллы"}},{"query":{"type":"jsonpath","expr":"$.url"},"filters":[{"type":"urlEncode"}],"predicate":{"type":"equal","value":"https%3A//mozilla.org/%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"}},{"query":{"type":"bytes"},"filters":[{"type":"decode","encoding":"iso-8859-1"},{"type":"xpath","expr":"string(//p)"}],"predicate":{"type":"equal","value":"Hello"}}]}}]}
4 changes: 3 additions & 1 deletion integration/hurlfmt/tests_export/filter.lint.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ HTTP 200
[Captures]
count: jsonpath "$.books" count
[Asserts]
jsonpath "$.data" base64Decode == hex,48656c6c6f; # base64Decode
bytes base64Encode == "SGVsbG8=" # base64Encode
jsonpath "$.books" count == 12 # count
certificate "Expire-Date" daysAfterNow > 15 # daysAfterNow
certificate "Start-Date" daysBeforeNow < 100 # daysBeforeNow
Expand All @@ -21,4 +23,4 @@ jsonpath "$.pi" toFloat == 3.14
jsonpath "$.id" toInt == 123 # toInt
jsonpath "$.encoded_url" urlDecode == "https://mozilla.org/?x=шеллы" # urlDecode
jsonpath "$.url" urlEncode == "https%3A//mozilla.org/%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B" # urlEncode
bytes decode "iso-8859-1" xpath "string(//p)" == "Hello" # xpath
bytes decode "iso-8859-1" xpath "string(//p)" == "Hello" # xpath

0 comments on commit 2b88b56

Please sign in to comment.