2010-01-03 00:38:06 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test git-http-backend-noserver'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
|
|
|
|
|
2014-05-23 22:19:34 +04:00
|
|
|
if test_have_prereq GREP_STRIPS_CR
|
|
|
|
then
|
|
|
|
GREP_OPTIONS=-U
|
|
|
|
export GREP_OPTIONS
|
|
|
|
fi
|
2010-09-12 13:37:24 +04:00
|
|
|
|
2010-01-03 00:38:06 +03:00
|
|
|
run_backend() {
|
2010-01-03 00:43:59 +03:00
|
|
|
echo "$2" |
|
2014-04-11 12:28:19 +04:00
|
|
|
QUERY_STRING="${1#*[?]}" \
|
|
|
|
PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
|
2010-01-03 00:38:06 +03:00
|
|
|
git http-backend >act.out 2>act.err
|
|
|
|
}
|
|
|
|
|
|
|
|
GET() {
|
2010-10-13 22:36:36 +04:00
|
|
|
REQUEST_METHOD="GET" && export REQUEST_METHOD &&
|
2010-01-03 00:43:59 +03:00
|
|
|
run_backend "/repo.git/$1" &&
|
2012-02-12 05:05:12 +04:00
|
|
|
sane_unset REQUEST_METHOD &&
|
2010-01-03 00:43:59 +03:00
|
|
|
if ! grep "Status" act.out >act
|
|
|
|
then
|
|
|
|
printf "Status: 200 OK\r\n" >act
|
|
|
|
fi
|
|
|
|
printf "Status: $2\r\n" >exp &&
|
|
|
|
test_cmp exp act
|
2010-01-03 00:38:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
POST() {
|
2010-10-13 22:36:36 +04:00
|
|
|
REQUEST_METHOD="POST" && export REQUEST_METHOD &&
|
|
|
|
CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
|
2010-01-03 00:43:59 +03:00
|
|
|
run_backend "/repo.git/$1" "$2" &&
|
2012-02-12 05:05:12 +04:00
|
|
|
sane_unset REQUEST_METHOD &&
|
|
|
|
sane_unset CONTENT_TYPE &&
|
2010-01-03 00:43:59 +03:00
|
|
|
if ! grep "Status" act.out >act
|
|
|
|
then
|
|
|
|
printf "Status: 200 OK\r\n" >act
|
|
|
|
fi
|
|
|
|
printf "Status: $3\r\n" >exp &&
|
|
|
|
test_cmp exp act
|
2010-01-03 00:38:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
log_div() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
. "$TEST_DIRECTORY"/t556x_common
|
|
|
|
|
|
|
|
expect_aliased() {
|
2010-10-13 22:36:36 +04:00
|
|
|
REQUEST_METHOD="GET" && export REQUEST_METHOD &&
|
2010-01-03 00:38:06 +03:00
|
|
|
if test $1 = 0; then
|
2010-01-15 09:44:02 +03:00
|
|
|
run_backend "$2"
|
2010-01-03 00:38:06 +03:00
|
|
|
else
|
2010-01-15 09:44:02 +03:00
|
|
|
run_backend "$2" &&
|
2010-01-03 00:38:06 +03:00
|
|
|
echo "fatal: '$2': aliased" >exp.err &&
|
|
|
|
test_cmp exp.err act.err
|
|
|
|
fi
|
2010-01-15 09:44:02 +03:00
|
|
|
unset REQUEST_METHOD
|
2010-01-03 00:38:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success 'http-backend blocks bad PATH_INFO' '
|
|
|
|
config http.getanyfile true &&
|
|
|
|
|
|
|
|
expect_aliased 0 /repo.git/HEAD &&
|
|
|
|
|
|
|
|
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
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|