Skip to content

Commit

Permalink
Update doc for Hurl 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Apr 10, 2024
1 parent 184de38 commit 8c2ef2b
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 112 deletions.
7 changes: 7 additions & 0 deletions sites/hurl.dev/_data/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
- title: Testing Set-Cookie Attributes
- title: Testing Bytes Content
- title: SSL Certificate
- title: Checking Full Body
- title: Reports
items:
- title: HTML Report
- title: JUnit Report
- title: TAP Report
- title: JSON Output
- title: Others
items:
- title: HTTP Version
Expand Down
14 changes: 8 additions & 6 deletions sites/hurl.dev/_docs/asserting-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ section: File Format

Asserts are used to test various properties of an HTTP response. Asserts can be implicits (such as version, status,
headers) or explicit within an `[Asserts]` section. The delimiter of the request / response is `HTTP <STATUS-CODE>`:
after this delimiter, you'll find the implicit asserts, then an `[Asserts]` section with all the explicits checks.
after this delimiter, you'll find the implicit asserts, then an `[Asserts]` section with all the explicit checks.


```hurl
GET https://api/example.org/cats
HTTP 200
Content-Type: application/json; charset=utf-8 # Implicit assert on Content-Type Hedaer
Content-Type: application/json; charset=utf-8 # Implicit assert on Content-Type Header
[Asserts] # Explicit asserts section
bytes count == 120
header "Content-Type" contains "utf-8"
Expand Down Expand Up @@ -174,7 +174,7 @@ Predicates consist of a predicate function and a predicate value. Predicate func

| Predicate | Description | Example |
|--------------------|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| __`==`__ | Query and predicate value are equals | `jsonpath "$.book" == "Dune"` |
| __`==`__ | Query and predicate value are equal | `jsonpath "$.book" == "Dune"` |
| __`!=`__ | Query and predicate value are different | `jsonpath "$.color" != "red"` |
| __`>`__ | Query number is greater than predicate value | `jsonpath "$.year" > 1978` |
| __`>=`__ | Query number is greater than or equal to the predicate value | `jsonpath "$.year" >= 1978` |
Expand All @@ -188,10 +188,11 @@ Predicates consist of a predicate function and a predicate value. Predicate func
| __`exists`__ | Query returns a value | `jsonpath "$.book" exists` |
| __`isBoolean`__ | Query returns a boolean | `jsonpath "$.succeeded" isBoolean` |
| __`isCollection`__ | Query returns a collection | `jsonpath "$.books" isCollection` |
| __`isDate`__ | Query returns a date | `jsonpath "$.publication_date" isDate` |
| __`isEmpty`__ | Query returns an empty collection | `jsonpath "$.movies" isEmpty` |
| __`isFloat`__ | Query returns a float | `jsonpath "$.height" isFloat` |
| __`isInteger`__ | Query returns an integer | `jsonpath "$.count" isInteger` |
| __`isIsoDate`__ | Query string returns a [RFC 3339] date (`YYYY-MM-DDTHH:mm:ss.sssZ`) | `jsonpath "$.publication_date" isIsoDate` |
| __`isNumber`__ | Query returns an integer or a float | `jsonpath "$.count" isNumber` |
| __`isString`__ | Query returns a string | `jsonpath "$.name" isString` |


Expand Down Expand Up @@ -373,7 +374,7 @@ cookie "LSID[Domain]" not exists
cookie "LSID[Path]" == "/accounts"
cookie "LSID[Secure]" exists
cookie "LSID[HttpOnly]" exists
cookie "LSID[SameSite]" equals "Lax"
cookie "LSID[SameSite]" == "Lax"
```

> `Secure` and `HttpOnly` attributes can only be tested with `exists` or `not exists` predicates
Expand Down Expand Up @@ -663,7 +664,7 @@ certificate "Serial-Number" matches "[0-9af]+"
## Body

Optional assertion on the received HTTP response body. Body section can be seen
as syntactic sugar over [body asserts] (with `equals` predicate function). If the
as syntactic sugar over [body asserts] (with `==` predicate). If the
body of the response is a [JSON] string or a [XML] string, the body assertion can
be directly inserted without any modification. For a text based body that is neither JSON nor XML,
one can use multiline string that starts with <code>&#96;&#96;&#96;</code> and ends
Expand Down Expand Up @@ -840,3 +841,4 @@ of all file nodes.
[count]: {% link _docs/filters.md %}#count
[`decode` filter]: {% link _docs/filters.md %}#decode
[headers implicit asserts]: #headers
[RFC 3339]: https://www.rfc-editor.org/rfc/rfc3339
2 changes: 1 addition & 1 deletion sites/hurl.dev/_docs/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ section: File Format
## Definition

[Captures] and [asserts] share a common structure: query. A query is used to extract data from an HTTP response; this data
can come from the HTTP response body, the HTTP response headers or from the HTTP meta-informations (like `duration` for instance)...
can come from the HTTP response body, the HTTP response headers or from the HTTP meta-information (like `duration` for instance)...

In this example, the query __`jsonpath "$.books[0].name"`__ is used in a capture to save data and in an assert to test
the HTTP response body.
Expand Down
9 changes: 4 additions & 5 deletions sites/hurl.dev/_docs/frequently-asked-questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ For example, the Hurl file
```hurl
GET https://example.org/api/users/1
User-Agent: Custom
HTTP/1.1 200
HTTP 200
[Asserts]
jsonpath "$.name" equals "Bob"
jsonpath "$.name" == "Bob"
```

will be converted to JSON with the following command:
Expand All @@ -215,7 +214,7 @@ $ hurlfmt test.hurl --out json | jq
]
},
"response": {
"version": "HTTP/1.1",
"version": "HTTP",
"status": 200,
"asserts": [
{
Expand All @@ -224,7 +223,7 @@ $ hurlfmt test.hurl --out json | jq
"expr": "$.name"
},
"predicate": {
"type": "equal",
"type": "==",
"value": "Bob"
}
}
Expand Down
Loading

0 comments on commit 8c2ef2b

Please sign in to comment.