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