mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-29 13:21:51 +00:00
add root tests
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
parent
966f8b6bdf
commit
2bc3a8e304
1 changed files with 84 additions and 0 deletions
84
caddytest/spec/http/root/spec.hurl
Normal file
84
caddytest/spec/http/root/spec.hurl
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# Configure Caddy with root directive
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
}
|
||||
localhost {
|
||||
root * {{indexed_root}}
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
# Root directive sets the file root for file_server
|
||||
GET https://localhost:9443/index.txt
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body == "index.txt"
|
||||
|
||||
|
||||
# Configure Caddy with conditional root
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
}
|
||||
localhost {
|
||||
root /api/* {{indexed_root}}
|
||||
root * {{unindexed_root}}
|
||||
respond {http.vars.root}
|
||||
}
|
||||
```
|
||||
|
||||
# Root is set conditionally based on path matcher
|
||||
GET https://localhost:9443/api/test
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body contains "indexed"
|
||||
|
||||
|
||||
# Different root for non-matching paths
|
||||
GET https://localhost:9443/other
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body contains "unindexed"
|
||||
|
||||
|
||||
# Configure Caddy with root using placeholders
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
}
|
||||
localhost {
|
||||
vars folder "indexed"
|
||||
root * caddytest/spec/http/file_server/assets/{vars.folder}
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
# Root can use placeholders
|
||||
GET https://localhost:9443/index.txt
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body == "index.txt"
|
||||
Loading…
Add table
Add a link
Reference in a new issue