1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
test_description='Check the preview server splits CGI output correctly'
CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
PYTHON=$(HOME=$USER_HOME python3 -I -c 'import sys; print(sys.executable)' 2>/dev/null)
test_lazy_prereq PYTHON '
test -n "$PYTHON" &&
"$PYTHON" -I -c "import sys; sys.exit(sys.version_info < (3, 8))"
'
test_have_prereq PYTHON || {
skip_all='Skipping preview server tests: no python3 3.8 or later'
test_done
}
split_check() {
"$PYTHON" -I "$TEST_OUTPUT_DIRECTORY/serve-split-check.py" \
"$TEST_OUTPUT_DIRECTORY/.." "$1"
}
test_expect_success 'a CRLF blank line in the body stays in the body' '
split_check crlf-in-body
'
test_expect_success 'an LF blank line after CRLF headers stays in the body' '
split_check lf-in-body
'
test_expect_success 'a status line is taken off the headers' '
split_check status
'
test_expect_success 'an empty body survives, as a redirect leaves one' '
split_check empty-body
'
test_expect_success 'output with no blank line at all is all headers' '
split_check no-blank-line
'
handler_check() {
mkdir "$1" &&
"$PYTHON" -I "$TEST_OUTPUT_DIRECTORY/serve-handler-check.py" \
"$TEST_OUTPUT_DIRECTORY/.." "$PWD/$1" "$1"
}
test_expect_success 'a request reaches the CGI with the environment it needs' '
handler_check environment
'
test_expect_success 'a request body reaches the CGI with its length' '
handler_check post-body
'
test_expect_success 'a root-level asset is served from the data directory' '
handler_check asset
'
test_expect_success 'a file of that name inside a repository goes to the CGI' '
handler_check repository-file
'
test_expect_success 'a link out of the data directory is no asset' '
handler_check asset-link-outside
'
test_expect_success 'a CGI that fails is answered with 500' '
handler_check failing-cgi
'
test_expect_success 'a CGI that stalls is answered with 504' '
handler_check stalled-cgi
'
test_expect_success 'a body over the cap is refused with 413' '
handler_check oversized-body
'
test_expect_success 'a HEAD request gets the headers alone' '
handler_check head
'
test_done
|