cocci: apply "pending" index-compatibility to "t/helper/*.c"
[git/debian.git] / t / t5560-http-backend-noserver.sh
blobd30cf4f5b8398e1cf98c86221dd42208d64fd014
1 #!/bin/sh
3 test_description='test git-http-backend-noserver'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
11 if test_have_prereq GREP_STRIPS_CR
12 then
13 GREP_OPTIONS=-U
14 export GREP_OPTIONS
17 run_backend() {
18 echo "$2" |
19 QUERY_STRING="${1#*[?]}" \
20 PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
21 git http-backend >act.out 2>act.err
24 GET() {
25 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
26 run_backend "/repo.git/$1" &&
27 sane_unset REQUEST_METHOD &&
28 if ! grep "Status" act.out >act
29 then
30 printf "Status: 200 OK\r\n" >act
32 printf "Status: $2\r\n" >exp &&
33 test_cmp exp act
36 POST() {
37 REQUEST_METHOD="POST" && export REQUEST_METHOD &&
38 CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
39 run_backend "/repo.git/$1" "$2" &&
40 sane_unset REQUEST_METHOD &&
41 sane_unset CONTENT_TYPE &&
42 if ! grep "Status" act.out >act
43 then
44 printf "Status: 200 OK\r\n" >act
46 printf "Status: $3\r\n" >exp &&
47 test_cmp exp act
50 . "$TEST_DIRECTORY"/t556x_common
52 expect_aliased() {
53 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
54 if test $1 = 0; then
55 run_backend "$2"
56 else
57 run_backend "$2" &&
58 echo "fatal: '$2': aliased" >exp.err &&
59 test_cmp exp.err act.err
61 unset REQUEST_METHOD
64 test_expect_success 'http-backend blocks bad PATH_INFO' '
65 config http.getanyfile true &&
67 expect_aliased 0 /repo.git/HEAD &&
69 expect_aliased 1 /repo.git/../HEAD &&
70 expect_aliased 1 /../etc/passwd &&
71 expect_aliased 1 ../etc/passwd &&
72 expect_aliased 1 /etc//passwd &&
73 expect_aliased 1 /etc/./passwd &&
74 expect_aliased 1 //domain/data.txt
77 test_done