-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing: use Hurl in CI to test Caddy against spec
- Loading branch information
1 parent
8f87c5d
commit 7611089
Showing
4 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Configure Caddy | ||
POST http://localhost:2019/load | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
debug | ||
} | ||
localhost { | ||
header "X-Custom-Header" "Custom-Value" | ||
} | ||
``` | ||
|
||
GET https://localhost:9443 | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
header "X-Custom-Header" == "Custom-Value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Configure Caddy | ||
POST http://localhost:2019/load | ||
User-Agent: hurl/ci | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
} | ||
localhost { | ||
rewrite /from /to | ||
respond {uri} | ||
} | ||
``` | ||
|
||
# simple scenario: rewriting /from to /to produces expected result of seeing /to | ||
GET https://localhost:9443/from | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
body == "/to" | ||
|
||
# unmatched path is passed through unchanged | ||
GET https://localhost:9443 | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
body == "/" | ||
|
||
# having a query parameter does not trip the rewrite and retains the query | ||
GET https://localhost:9443/from?query_param=value | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
body == "/to?query_param=value" | ||
|
||
|
||
# Configure Caddy | ||
POST http://localhost:2019/load | ||
User-Agent: hurl/ci | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
} | ||
localhost { | ||
rewrite /from /to?a=b | ||
respond {uri} | ||
} | ||
``` | ||
|
||
# a rewrite with query parameters affects the parameters | ||
GET https://localhost:9443/from?query_param=value | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
body == "/to?a=b" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Configure Caddy | ||
POST http://localhost:2019/load | ||
User-Agent: hurl/ci | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
} | ||
localhost { | ||
log | ||
respond "Hello, World!" | ||
} | ||
``` | ||
|
||
GET https://localhost:9443 | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
`Hello, World!` | ||
|
||
|
||
GET https://localhost:9443/foo | ||
[Options] | ||
insecure: true | ||
HTTP 200 | ||
[Asserts] | ||
`Hello, World!` | ||
|
||
# Configure Caddy | ||
POST http://localhost:2019/load | ||
User-Agent: hurl/ci | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
} | ||
localhost { | ||
respond "New text!" | ||
} | ||
``` | ||
|
||
GET https://localhost:9443 | ||
[Options] | ||
insecure: true | ||
HTTP/2 200 | ||
[Asserts] | ||
`New text!` | ||
|
||
|
||
GET https://localhost:9443/foo | ||
[Options] | ||
insecure: true | ||
HTTP/2 200 | ||
[Asserts] | ||
`New text!` | ||
|
||
GET https://localhost:9443/foo | ||
[Options] | ||
insecure: true | ||
HTTP/2 200 | ||
[Asserts] | ||
body != "Hello, World!" | ||
|
||
# Configure Caddy | ||
# The body is a placeholder | ||
POST http://localhost:2019/load | ||
User-Agent: hurl/ci | ||
Content-Type: text/caddyfile | ||
``` | ||
{ | ||
skip_install_trust | ||
http_port 9080 | ||
https_port 9443 | ||
local_certs | ||
} | ||
localhost { | ||
log | ||
respond {http.request.body} | ||
} | ||
``` | ||
|
||
# handler responds with the "application/json" if the response body is valid JSON | ||
POST https://localhost:9443 | ||
[Options] | ||
insecure: true | ||
```json | ||
{ | ||
"greeting": "Hello, world!" | ||
} | ||
``` | ||
HTTP/2 200 | ||
[Asserts] | ||
header "Content-Type" == "application/json" | ||
```json | ||
{ | ||
"greeting": "Hello, world!" | ||
} | ||
``` |