2022-10-07 22:31:00 +03:00
< 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 >
2022-11-11 16:25:00 +03:00
< / span > < span class = "response" > < span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
2022-12-02 22:50:27 +03:00
< span class = "line" > < span class = "string" > `Hello World!`< / span > < / span >
2022-10-07 22:31:00 +03:00
< / 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 >
2022-11-11 16:25:00 +03:00
< span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Asserts]< / span > < / span >
2022-10-07 22:31:00 +03:00
< 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 >
2022-11-11 16:25:00 +03:00
< span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 302< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Asserts]< / span > < / span >
2022-10-07 22:31:00 +03:00
< 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 >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Options]< / span > < / span >
2023-04-17 14:05:34 +03:00
< span class = "line" > < span class = "string" > location< / span > : < span class = "boolean" > true< / span > < / span >
2022-10-07 22:31:00 +03:00
< / span > < span class = "response" > < span class = "line" > < / span >
2022-11-11 16:25:00 +03:00
< span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Asserts]< / span > < / span >
2022-10-07 22:31:00 +03:00
< 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 >
2022-12-02 22:50:27 +03:00
< span class = "line" > < span class = "string" > `Followed redirect!`< / span > < / span >
2022-10-07 22:31:00 +03:00
< / 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 >
2022-11-11 16:25:00 +03:00
< span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Captures]< / span > < / span >
2023-04-17 14:05:34 +03:00
< 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 >
2022-10-07 22:31:00 +03:00
< / 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 >
2022-11-11 16:25:00 +03:00
< span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [Asserts]< / span > < / span >
2022-10-07 22:31:00 +03:00
< 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 >
2022-10-24 12:37:11 +03:00
< / code > < / pre >