Skip to content

Commit 7e174a0

Browse files
committed
add file_server test
Signed-off-by: Mohammed Al Sahaf <[email protected]>
1 parent 0ecb1ba commit 7e174a0

File tree

5 files changed

+119
-1
lines changed

5 files changed

+119
-1
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
if: matrix.os == 'linux' && matrix.go == '1.22'
146146
run: |
147147
mkdir hurl-report
148-
find . -name *.hurl -exec hurl --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \;
148+
find . -name *.hurl -exec hurl --variable indexed_root=$PWD/caddytest/spec/http/file_server/assets/indexed --variable unindexed_root=$PWD/caddytest/spec/http/file_server/assets/unindexed --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \;
149149
150150
- name: Publish Test Results
151151
if: matrix.os == 'linux' && matrix.go == '1.22'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Index.html Title</title>
5+
</head>
6+
<body>
7+
Index.html
8+
</body>
9+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.txt

caddytest/spec/http/file_server/assets/unindexed/.gitkeep

Whitespace-only changes.
+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Configure Caddy with default configuration
2+
POST http://localhost:2019/load
3+
Content-Type: text/caddyfile
4+
```
5+
{
6+
skip_install_trust
7+
http_port 9080
8+
https_port 9443
9+
local_certs
10+
debug
11+
}
12+
localhost {
13+
root {{indexed_root}}
14+
file_server
15+
}
16+
```
17+
18+
# requests without specific file receive index file per
19+
# the default index list: index.html, index.txt
20+
GET https://localhost:9443
21+
[Options]
22+
insecure: true
23+
HTTP 200
24+
[Asserts]
25+
```
26+
<!DOCTYPE html>
27+
<html>
28+
<head>
29+
<title>Index.html Title</title>
30+
</head>
31+
<body>
32+
Index.html
33+
</body>
34+
</html>```
35+
36+
37+
# if index.txt is specifically requested, we expect index.txt
38+
GET https://localhost:9443/index.txt
39+
[Options]
40+
insecure: true
41+
HTTP 200
42+
[Asserts]
43+
body == "index.txt"
44+
45+
# requests for sub-folder folloed by .. result in sanitized path
46+
GET https://localhost:9443/non-existent/../index.txt
47+
[Options]
48+
insecure: true
49+
HTTP 200
50+
[Asserts]
51+
body == "index.txt"
52+
53+
GET https://localhost:9443/../
54+
[Options]
55+
insecure: true
56+
HTTP 200
57+
[Asserts]
58+
body == "index.txt"
59+
60+
61+
# Configure Caddy with custsom index "index.txt"
62+
POST http://localhost:2019/load
63+
Content-Type: text/caddyfile
64+
```
65+
{
66+
skip_install_trust
67+
http_port 9080
68+
https_port 9443
69+
local_certs
70+
debug
71+
}
72+
localhost {
73+
root {{indexed_root}}
74+
file_server {
75+
index index.txt
76+
}
77+
}
78+
```
79+
80+
GET https://localhost:9443
81+
[Options]
82+
insecure: true
83+
HTTP 200
84+
[Asserts]
85+
body == "index.txt"
86+
87+
88+
# Configure with a root not containing index files
89+
POST http://localhost:2019/load
90+
Content-Type: text/caddyfile
91+
```
92+
{
93+
skip_install_trust
94+
http_port 9080
95+
https_port 9443
96+
local_certs
97+
debug
98+
}
99+
localhost {
100+
root {{unindexed_root}}
101+
file_server
102+
}
103+
```
104+
105+
GET https://localhost:9443
106+
[Options]
107+
insecure: true
108+
HTTP 404

0 commit comments

Comments
 (0)