pull: replace unnecessary sed invocation
[git/mjg.git] / t / t5560-http-backend-noserver.sh
blob44885b850c4a1c3a09b8b078a643cf7cd8918213
1 #!/bin/sh
3 test_description='test git-http-backend-noserver'
4 . ./test-lib.sh
6 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
8 run_backend() {
9 echo "$2" |
10 QUERY_STRING="${1#*\?}" \
11 GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
12 PATH_INFO="${1%%\?*}" \
13 git http-backend >act.out 2>act.err
16 GET() {
17 export REQUEST_METHOD="GET" &&
18 run_backend "/repo.git/$1" &&
19 unset REQUEST_METHOD &&
20 if ! grep "Status" act.out >act
21 then
22 printf "Status: 200 OK\r\n" >act
24 printf "Status: $2\r\n" >exp &&
25 test_cmp exp act
28 POST() {
29 export REQUEST_METHOD="POST" &&
30 export CONTENT_TYPE="application/x-$1-request" &&
31 run_backend "/repo.git/$1" "$2" &&
32 unset REQUEST_METHOD &&
33 unset CONTENT_TYPE &&
34 if ! grep "Status" act.out >act
35 then
36 printf "Status: 200 OK\r\n" >act
38 printf "Status: $3\r\n" >exp &&
39 test_cmp exp act
42 log_div() {
43 return 0
46 . "$TEST_DIRECTORY"/t556x_common
48 expect_aliased() {
49 export REQUEST_METHOD="GET" &&
50 if test $1 = 0; then
51 run_backend "$2"
52 else
53 run_backend "$2" &&
54 echo "fatal: '$2': aliased" >exp.err &&
55 test_cmp exp.err act.err
57 unset REQUEST_METHOD
60 test_expect_success 'http-backend blocks bad PATH_INFO' '
61 config http.getanyfile true &&
63 expect_aliased 0 /repo.git/HEAD &&
65 expect_aliased 1 /repo.git/../HEAD &&
66 expect_aliased 1 /../etc/passwd &&
67 expect_aliased 1 ../etc/passwd &&
68 expect_aliased 1 /etc//passwd &&
69 expect_aliased 1 /etc/./passwd &&
70 expect_aliased 1 //domain/data.txt
73 test_done