t / t5560-http-backend-noserver.shon commit wt-status.c: set commitable bit if there is a meaningful merge. (8dc874b)
   1#!/bin/sh
   2
   3test_description='test git-http-backend-noserver'
   4. ./test-lib.sh
   5
   6HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
   7
   8if test_have_prereq GREP_STRIPS_CR
   9then
  10        GREP_OPTIONS=-U
  11        export GREP_OPTIONS
  12fi
  13
  14run_backend() {
  15        echo "$2" |
  16        QUERY_STRING="${1#*[?]}" \
  17        PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
  18        git http-backend >act.out 2>act.err
  19}
  20
  21GET() {
  22        REQUEST_METHOD="GET" && export REQUEST_METHOD &&
  23        run_backend "/repo.git/$1" &&
  24        sane_unset REQUEST_METHOD &&
  25        if ! grep "Status" act.out >act
  26        then
  27                printf "Status: 200 OK\r\n" >act
  28        fi
  29        printf "Status: $2\r\n" >exp &&
  30        test_cmp exp act
  31}
  32
  33POST() {
  34        REQUEST_METHOD="POST" && export REQUEST_METHOD &&
  35        CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
  36        run_backend "/repo.git/$1" "$2" &&
  37        sane_unset REQUEST_METHOD &&
  38        sane_unset CONTENT_TYPE &&
  39        if ! grep "Status" act.out >act
  40        then
  41                printf "Status: 200 OK\r\n" >act
  42        fi
  43        printf "Status: $3\r\n" >exp &&
  44        test_cmp exp act
  45}
  46
  47log_div() {
  48        return 0
  49}
  50
  51. "$TEST_DIRECTORY"/t556x_common
  52
  53expect_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
  61        fi
  62        unset REQUEST_METHOD
  63}
  64
  65test_expect_success 'http-backend blocks bad PATH_INFO' '
  66        config http.getanyfile true &&
  67
  68        expect_aliased 0 /repo.git/HEAD &&
  69
  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
  76'
  77
  78test_done