t5561: get rid of racy appending to logfile
[git/debian.git] / t / t5560-http-backend-noserver.sh
blob9d54ef478c24c9062d181a086e0a2a929600c3e3
1 #!/bin/sh
3 test_description='test git-http-backend-noserver'
4 . ./test-lib.sh
6 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
8 test_have_prereq GREP_STRIPS_CR && export GREP_OPTIONS=-U
10 run_backend() {
11 echo "$2" |
12 QUERY_STRING="${1#*[?]}" \
13 PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
14 git http-backend >act.out 2>act.err
17 GET() {
18 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
19 run_backend "/repo.git/$1" &&
20 sane_unset REQUEST_METHOD &&
21 if ! grep "Status" act.out >act
22 then
23 printf "Status: 200 OK\r\n" >act
25 printf "Status: $2\r\n" >exp &&
26 test_cmp exp act
29 POST() {
30 REQUEST_METHOD="POST" && export REQUEST_METHOD &&
31 CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
32 run_backend "/repo.git/$1" "$2" &&
33 sane_unset REQUEST_METHOD &&
34 sane_unset CONTENT_TYPE &&
35 if ! grep "Status" act.out >act
36 then
37 printf "Status: 200 OK\r\n" >act
39 printf "Status: $3\r\n" >exp &&
40 test_cmp exp act
43 . "$TEST_DIRECTORY"/t556x_common
45 expect_aliased() {
46 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
47 if test $1 = 0; then
48 run_backend "$2"
49 else
50 run_backend "$2" &&
51 echo "fatal: '$2': aliased" >exp.err &&
52 test_cmp exp.err act.err
54 unset REQUEST_METHOD
57 test_expect_success 'http-backend blocks bad PATH_INFO' '
58 config http.getanyfile true &&
60 expect_aliased 0 /repo.git/HEAD &&
62 expect_aliased 1 /repo.git/../HEAD &&
63 expect_aliased 1 /../etc/passwd &&
64 expect_aliased 1 ../etc/passwd &&
65 expect_aliased 1 /etc//passwd &&
66 expect_aliased 1 /etc/./passwd &&
67 expect_aliased 1 //domain/data.txt
70 test_done