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"
|
|
|
|
|
2010-09-12 13:37:24 +04:00
|
|
|
test_have_prereq MINGW && export GREP_OPTIONS=-U
|
|
|
|
|
2010-01-03 00:38:06 +03:00
|
|
|
run_backend() {
|
2010-01-03 00:43:59 +03:00
|
|
|
echo "$2" |
|
|
|
|
QUERY_STRING="${1#*\?}" \
|
Side-step MSYS-specific path "corruption" leading to t5560 failure.
Upon program invocation, MSYS converts environment variables containing
path-like values from Unix-style to DOS-style under the assumption that
the program being invoked understands only DOS-style pathnames. For
instance, the Unix-style path /msysgit is translated to c:/msysgit. For
test t5560, the path being requested from git-http-backend is specified
via environment variable PATH_INFO as a URL path of the form
/repo.git/foobar, which git-http-backend combines with GIT_PROJECT_ROOT
to determine the actual physical path within the repository. This is a
case where MSYS's conversion of the path-like value of PATH_INFO causes
harm, for two reasons. First, the resulting converted path, when joined
with GIT_PROJECT_ROOT is bogus (for instance,
"C:/msysgit/git/t/trash-zzz/C:/msysgit/repo.git/HEAD"). Second, the
converted PATH_INFO path is rejected by git-http-backend as an 'alias'
due to validation failure on the part of daemon_avoid_alias().
Unfortunately, the standard work-around of doubling the leading slash
(i.e. //repo.git/foobar) to suppress MSYS path conversion works only for
command-line arguments, but not for environment variables.
Consequently, side step the problem by instead passing git-http-backend
an already-constructed full path rather than components GIT_PROJECT_ROOT
and PATH_INFO.
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2010-07-21 03:29:16 +04:00
|
|
|
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" &&
|
2010-01-15 09:44:02 +03:00
|
|
|
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" &&
|
2010-01-15 09:44:02 +03:00
|
|
|
unset REQUEST_METHOD &&
|
|
|
|
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
|