mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 10:56:09 +03:00
bf79a512e0
hurlfmt now also outputs a trailing newline.
60 lines
5.4 KiB
HTML
60 lines
5.4 KiB
HTML
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># A test file with asserts, captures, redirection</span>
|
|
<span class="line"></span><span class="comment"># to test structured JSON output (with --json).</span>
|
|
<span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Simple GET</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="raw"><span class="line">```Hello World!```</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Cookies!</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/cookies/set-session-cookie2-valueA</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">cookie</span> <span class="string">"cookie2"</span> <span class="predicate-type">==</span> <span class="string">"valueA"</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># No redirect</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/follow-redirect</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">302</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">header</span> <span class="string">"Location"</span> <span class="predicate-type">==</span> <span class="string">"http://localhost:8000/following-redirect"</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># With redirect</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/follow-redirect</span></span>
|
|
<span class="line section-header">[Options]</span>
|
|
<span class="line"><span class="string">location</span><span>:</span> <span class="boolean">true</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">header</span> <span class="string">"Location"</span> <span class="not">not</span> <span class="predicate-type">exists</span></span>
|
|
<span class="raw"><span class="line">```Followed redirect!```</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Some Captures</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/captures</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Captures]</span>
|
|
<span class="line"><span class="name">param1</span><span>:</span> <span class="query-type">header</span> <span class="string">"header1"</span></span>
|
|
<span class="line"><span class="name">param2</span><span>:</span> <span class="query-type">header</span> <span class="string">"header2"</span> <span class="subquery-type">regex</span> <span class="string">"Hello (.*)!"</span></span>
|
|
<span class="line"><span class="name">param3</span><span>:</span> <span class="query-type">header</span> <span class="string">"header2"</span> <span class="subquery-type">regex</span> <span class="regex">/Hello (.*)!/</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"></span><span class="comment"># Some JSON asserts</span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Asserts]</span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[1].id"</span> <span class="predicate-type">==</span> <span class="string">"error2"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="predicate-type">includes</span> <span class="string">"test"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="not">not</span> <span class="predicate-type">includes</span> <span class="string">"prod"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="not">not</span> <span class="predicate-type">includes</span> <span class="null">null</span></span>
|
|
</span></span><span class="line"></span>
|
|
<span class="line"></span>
|
|
</code></pre>
|