mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-22 10:31:46 +03:00
62 lines
5.7 KiB
HTML
62 lines
5.7 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</span> <span class="number">200</span></span>
|
|
<span class="line"><span class="string">`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</span> <span class="number">200</span></span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></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</span> <span class="number">302</span></span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></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"><span class="section-header">[Options]</span></span>
|
|
<span class="line"><span class="string">location</span>: <span class="boolean">true</span></span>
|
|
</span><span class="response"><span class="line"></span>
|
|
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></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="line"><span class="string">`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</span> <span class="number">200</span></span>
|
|
<span class="line"><span class="section-header">[Captures]</span></span>
|
|
<span class="line"><span class="name">param1</span>: <span class="query-type">header</span> <span class="string">"header1"</span></span>
|
|
<span class="line"><span class="name">param2</span>: <span class="query-type">header</span> <span class="string">"header2"</span> <span class="filter-type">regex</span> <span class="string">"Hello (.*)!"</span></span>
|
|
<span class="line"><span class="name">param3</span>: <span class="query-type">header</span> <span class="string">"header2"</span> <span class="filter-type">regex</span> <span class="regex">/Hello (.*)!/</span></span>
|
|
<span class="line"><span class="name">data1</span>: <span class="query-type">body</span></span>
|
|
<span class="line"><span class="name">data2</span>: <span class="query-type">variable</span> <span class="string">"data1"</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</span> <span class="number">200</span></span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></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>
|