builtin/am: allow disabling conflict advice
[alt-git.git] / t / t5560-http-backend-noserver.sh
blobf75068de64851faf86d7ae270c1b88bb9d08df16
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_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
12 if test_have_prereq GREP_STRIPS_CR
13 then
14 GREP_OPTIONS=-U
15 export GREP_OPTIONS
18 run_backend() {
19 echo "$2" |
20 QUERY_STRING="${1#*[?]}" \
21 PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
22 git http-backend >act.out 2>act.err
25 GET() {
26 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
27 run_backend "/repo.git/$1" &&
28 sane_unset REQUEST_METHOD &&
29 if ! grep "Status" act.out >act
30 then
31 printf "Status: 200 OK\r\n" >act
33 printf "Status: $2\r\n" >exp &&
34 test_cmp exp act
37 POST() {
38 REQUEST_METHOD="POST" && export REQUEST_METHOD &&
39 CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
40 run_backend "/repo.git/$1" "$2" &&
41 sane_unset REQUEST_METHOD &&
42 sane_unset CONTENT_TYPE &&
43 if ! grep "Status" act.out >act
44 then
45 printf "Status: 200 OK\r\n" >act
47 printf "Status: $3\r\n" >exp &&
48 test_cmp exp act
51 . "$TEST_DIRECTORY"/t556x_common
53 expect_aliased() {
54 REQUEST_METHOD="GET" && export REQUEST_METHOD &&
55 if test $1 = 0; then
56 run_backend "$2"
57 else
58 run_backend "$2" &&
59 echo "fatal: '$2': aliased" >exp.err &&
60 test_cmp exp.err act.err
62 unset REQUEST_METHOD
65 test_expect_success 'http-backend blocks bad PATH_INFO' '
66 config http.getanyfile true &&
68 expect_aliased 0 /repo.git/HEAD &&
70 expect_aliased 1 /repo.git/../HEAD &&
71 expect_aliased 1 /../etc/passwd &&
72 expect_aliased 1 ../etc/passwd &&
73 expect_aliased 1 /etc//passwd &&
74 expect_aliased 1 /etc/./passwd &&
75 expect_aliased 1 //domain/data.txt
78 test_done