mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-12 19:17:03 +01:00
add file_server
test
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
parent
0ecb1ba262
commit
c1cdc25b77
6 changed files with 133 additions and 3 deletions
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -137,15 +137,14 @@ jobs:
|
|||
|
||||
- name: Run Caddy
|
||||
if: matrix.os == 'linux' && matrix.go == '1.22'
|
||||
working-directory: ./cmd/caddy
|
||||
run: |
|
||||
./caddy start
|
||||
./cmd/caddy/caddy start
|
||||
|
||||
- name: Run tests with Hurl
|
||||
if: matrix.os == 'linux' && matrix.go == '1.22'
|
||||
run: |
|
||||
mkdir hurl-report
|
||||
find . -name *.hurl -exec hurl --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \;
|
||||
find . -name *.hurl -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \;
|
||||
|
||||
- name: Publish Test Results
|
||||
if: matrix.os == 'linux' && matrix.go == '1.22'
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Index.html Title</title>
|
||||
</head>
|
||||
<body>
|
||||
Index.html
|
||||
</body>
|
||||
</html>
|
1
caddytest/spec/http/file_server/assets/indexed/index.txt
Normal file
1
caddytest/spec/http/file_server/assets/indexed/index.txt
Normal file
|
@ -0,0 +1 @@
|
|||
index.txt
|
119
caddytest/spec/http/file_server/spec.hurl
Normal file
119
caddytest/spec/http/file_server/spec.hurl
Normal file
|
@ -0,0 +1,119 @@
|
|||
# Configure Caddy with default configuration
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
debug
|
||||
}
|
||||
localhost {
|
||||
root {{indexed_root}}
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
# requests without specific file receive index file per
|
||||
# the default index list: index.html, index.txt
|
||||
GET https://localhost:9443
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Index.html Title</title>
|
||||
</head>
|
||||
<body>
|
||||
Index.html
|
||||
</body>
|
||||
</html>```
|
||||
|
||||
|
||||
# if index.txt is specifically requested, we expect index.txt
|
||||
GET https://localhost:9443/index.txt
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body == "index.txt"
|
||||
|
||||
# requests for sub-folder followed by .. result in sanitized path
|
||||
GET https://localhost:9443/non-existent/../index.txt
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body == "index.txt"
|
||||
|
||||
# results out of root folder are sanitized,
|
||||
# and conform to default index list sequence.
|
||||
GET https://localhost:9443/../
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Index.html Title</title>
|
||||
</head>
|
||||
<body>
|
||||
Index.html
|
||||
</body>
|
||||
</html>```
|
||||
|
||||
|
||||
# Configure Caddy with custsom index "index.txt"
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
debug
|
||||
}
|
||||
localhost {
|
||||
root {{indexed_root}}
|
||||
file_server {
|
||||
index index.txt
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
GET https://localhost:9443
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body == "index.txt"
|
||||
|
||||
|
||||
# Configure with a root not containing index files
|
||||
POST http://localhost:2019/load
|
||||
Content-Type: text/caddyfile
|
||||
```
|
||||
{
|
||||
skip_install_trust
|
||||
http_port 9080
|
||||
https_port 9443
|
||||
local_certs
|
||||
debug
|
||||
}
|
||||
localhost {
|
||||
root {{unindexed_root}}
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
GET https://localhost:9443
|
||||
[Options]
|
||||
insecure: true
|
||||
HTTP 404
|
2
caddytest/spec/hurl_vars.properties
Normal file
2
caddytest/spec/hurl_vars.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
indexed_root=caddytest/spec/http/file_server/assets/indexed
|
||||
unindexed_root=caddytest/spec/http/file_server/assets/unindexed
|
Loading…
Reference in a new issue