Skip to content

Commit

Permalink
Smart-http tests: Improve coverage in test t5560
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tarmigan Casebolt authored and Junio C Hamano committed Jan 6, 2010
1 parent 8b2bd7c commit 4301577
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions t/t5560-http-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '
run_backend() {
REQUEST_METHOD=GET \
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
PATH_INFO="$2" \
PATH_INFO="$1" \
git http-backend >act.out 2>act.err
}

path_info() {
expect_aliased() {
if test $1 = 0; then
run_backend "$2"
else
test_must_fail run_backend "$2" &&
run_backend "$2" &&
echo "fatal: '$2': aliased" >exp.err &&
test_cmp exp.err act.err
fi
Expand All @@ -179,15 +179,14 @@ path_info() {
test_expect_success 'http-backend blocks bad PATH_INFO' '
config http.getanyfile true &&
run_backend 0 /repo.git/HEAD &&
expect_aliased 0 /repo.git/HEAD &&
run_backend 1 /repo.git/../HEAD &&
run_backend 1 /../etc/passwd &&
run_backend 1 ../etc/passwd &&
run_backend 1 /etc//passwd &&
run_backend 1 /etc/./passwd &&
run_backend 1 /etc/.../passwd &&
run_backend 1 //domain/data.txt
expect_aliased 1 /repo.git/../HEAD &&
expect_aliased 1 /../etc/passwd &&
expect_aliased 1 ../etc/passwd &&
expect_aliased 1 /etc//passwd &&
expect_aliased 1 /etc/./passwd &&
expect_aliased 1 //domain/data.txt
'

cat >exp <<EOF
Expand Down

0 comments on commit 4301577

Please sign in to comment.