Skip to content

Commit 4301577

Browse files
Tarmigan Caseboltgitster
authored andcommitted
Smart-http tests: Improve coverage in test t5560
Commit 34b6cb8 ("http-backend: Protect GIT_PROJECT_ROOT from /../ requests") added the path_info helper function to test t5560 but did not use it. We should use it as it provides another level of error checking. The /etc/.../passwd case is one that is not special (and the test fails for reasons other than being aliased), so we remove that test case. Also rename the function from 'path_info' to 'expect_aliased'. Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8b2bd7c commit 4301577

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

t/t5560-http-backend.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '
162162
run_backend() {
163163
REQUEST_METHOD=GET \
164164
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
165-
PATH_INFO="$2" \
165+
PATH_INFO="$1" \
166166
git http-backend >act.out 2>act.err
167167
}
168168

169-
path_info() {
169+
expect_aliased() {
170170
if test $1 = 0; then
171171
run_backend "$2"
172172
else
173-
test_must_fail run_backend "$2" &&
173+
run_backend "$2" &&
174174
echo "fatal: '$2': aliased" >exp.err &&
175175
test_cmp exp.err act.err
176176
fi
@@ -179,15 +179,14 @@ path_info() {
179179
test_expect_success 'http-backend blocks bad PATH_INFO' '
180180
config http.getanyfile true &&
181181
182-
run_backend 0 /repo.git/HEAD &&
182+
expect_aliased 0 /repo.git/HEAD &&
183183
184-
run_backend 1 /repo.git/../HEAD &&
185-
run_backend 1 /../etc/passwd &&
186-
run_backend 1 ../etc/passwd &&
187-
run_backend 1 /etc//passwd &&
188-
run_backend 1 /etc/./passwd &&
189-
run_backend 1 /etc/.../passwd &&
190-
run_backend 1 //domain/data.txt
184+
expect_aliased 1 /repo.git/../HEAD &&
185+
expect_aliased 1 /../etc/passwd &&
186+
expect_aliased 1 ../etc/passwd &&
187+
expect_aliased 1 /etc//passwd &&
188+
expect_aliased 1 /etc/./passwd &&
189+
expect_aliased 1 //domain/data.txt
191190
'
192191

193192
cat >exp <<EOF

0 commit comments

Comments
 (0)