Skip to content

Commit 6c91373

Browse files
committed
test: add app test cases
1 parent 4f9ab24 commit 6c91373

23 files changed

+280
-0
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ insert_final_newline = true
66
indent_style = tab
77
indent_size = 4
88
charset = utf-8
9+
10+
[test/**]
11+
insert_final_newline = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.*/
22
/output
3+
/test/bin/

test/case/001.basic.bash

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 &
6+
7+
file1=$(http_get_body 127.0.0.1:3003/file1.txt)
8+
assert "$file1" 'vhost1/file1.txt'
9+
10+
kill %1

test/case/002.vhost.bash

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 --hostname=127.0.0.1 ,, -l 3003 -r "$fs"/vhost2 --hostname=127.0.0.2 &
6+
7+
vh1file1=$(http_get_body 127.0.0.1:3003/file1.txt)
8+
assert "$vh1file1" 'vhost1/file1.txt'
9+
10+
vh2file1=$(http_get_body 127.0.0.2:3003/file1.txt)
11+
assert "$vh2file1" 'vhost2/file1.txt'
12+
13+
kill %1

test/case/003.vhost.tls.bash

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 --hostname=127.0.0.1 -c "$cert"/example.crt -k "$cert"/example.key ,, -l 3003 -r "$fs"/vhost2 --hostname=127.0.0.2 -c "$cert"/localhost.crt -k "$cert"/localhost.key &
6+
7+
vh1file1=$(https_get_body 127.0.0.1:3003/file1.txt)
8+
assert "$vh1file1" 'vhost1/file1.txt'
9+
10+
vh2file1=$(https_get_body 127.0.0.2:3003/file1.txt)
11+
assert "$vh2file1" 'vhost2/file1.txt'
12+
13+
kill %1

test/case/004.alias.bash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 -a :world:"$fs"/vhost1/go :/not/exist/name:"$fs"/vhost1/yes &
6+
7+
file1=$(http_get_body 127.0.0.1:3003/file1.txt)
8+
assert "$file1" 'vhost1/file1.txt'
9+
10+
hello=$(http_get_body 127.0.0.1:3003/hello/index.txt)
11+
assert "$hello" 'vhost1/hello/index.txt'
12+
13+
go=$(http_get_body 127.0.0.1:3003/world/index.txt)
14+
assert "$go" 'vhost1/go/index.txt'
15+
16+
yes=$(http_get_body 127.0.0.1:3003/not/exist/name/index.txt)
17+
assert "$yes" 'vhost1/yes/index.txt'
18+
19+
kill %1

test/case/005.alias.empty.root.bash

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -R -a :world:"$fs"/vhost1/go :/not/exist/name:"$fs"/vhost1/yes &
6+
7+
file1status=$(http_get_status 127.0.0.1:3003/file1.txt | head -n 1 | cut -d ' ' -f 2)
8+
assert "$file1status" '404'
9+
10+
file1headstatus=$(http_head_status 127.0.0.1:3003/file1.txt | head -n 1 | cut -d ' ' -f 2)
11+
assert "$file1headstatus" '404'
12+
13+
hellostatus=$(http_get_status 127.0.0.1:3003/hello/index.txt | head -n 1 | cut -d ' ' -f 2)
14+
assert "$hellostatus" '404'
15+
16+
helloheadstatus=$(http_head_status 127.0.0.1:3003/hello/index.txt | head -n 1 | cut -d ' ' -f 2)
17+
assert "$helloheadstatus" '404'
18+
19+
go=$(http_get_body 127.0.0.1:3003/world/index.txt)
20+
assert "$go" 'vhost1/go/index.txt'
21+
22+
yes=$(http_get_body 127.0.0.1:3003/not/exist/name/index.txt)
23+
assert "$yes" 'vhost1/yes/index.txt'
24+
25+
kill %1

test/case/006.auth.bash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 --auth /hello --user alice:AliceSecret &
6+
7+
yesstatus=$(http_get_status 127.0.0.1:3003/yes/)
8+
assert "$yesstatus" '200'
9+
10+
hellostatus=$(http_get_status 127.0.0.1:3003/hello/)
11+
assert "$hellostatus" '401'
12+
13+
userhellostatus=$(http_get_status alice:[email protected]:3003/hello/)
14+
assert "$userhellostatus" '200'
15+
16+
userhelloheadstatus=$(http_head_status alice:[email protected]:3003/hello/)
17+
assert "$userhelloheadstatus" '200'
18+
19+
kill %1

test/case/007.dir.index.bash

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 -I index.txt &
6+
7+
yes=$(http_get_body 127.0.0.1:3003/yes)
8+
assert "$yes" 'vhost1/yes/index.txt'
9+
10+
kill %1

test/cert/example.crt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDwjCCAqqgAwIBAgIJALFGxLR0X6MLMA0GCSqGSIb3DQEBCwUAMHYxCzAJBgNV
3+
BAYTAkNOMREwDwYDVQQIDAhaaGVKaWFuZzERMA8GA1UEBwwISGFuZ1pob3UxFDAS
4+
BgNVBAoMC0NvbXBhbnlOYW1lMRcwFQYDVQQLDA5EZXBhcnRtZW50TmFtZTESMBAG
5+
A1UEAww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