t / t5561-http-backend.shon commit git_connect: clear GIT_* environment for ssh (aab4043)
   1#!/bin/sh
   2
   3test_description='test git-http-backend'
   4. ./test-lib.sh
   5. "$TEST_DIRECTORY"/lib-httpd.sh
   6start_httpd
   7
   8GET() {
   9        curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
  10        tr '\015' Q <out |
  11        sed '
  12                s/Q$//
  13                1q
  14        ' >act &&
  15        echo "HTTP/1.1 $2" >exp &&
  16        test_cmp exp act
  17}
  18
  19POST() {
  20        curl --include --data "$2" \
  21        --header "Content-Type: application/x-$1-request" \
  22        "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
  23        tr '\015' Q <out |
  24        sed '
  25                s/Q$//
  26                1q
  27        ' >act &&
  28        echo "HTTP/1.1 $3" >exp &&
  29        test_cmp exp act
  30}
  31
  32log_div() {
  33        echo >>"$HTTPD_ROOT_PATH"/access.log
  34        echo "###  $1" >>"$HTTPD_ROOT_PATH"/access.log
  35        echo "###" >>"$HTTPD_ROOT_PATH"/access.log
  36}
  37
  38. "$TEST_DIRECTORY"/t556x_common
  39
  40cat >exp <<EOF
  41
  42###  refs/heads/master
  43###
  44GET  /smart/repo.git/refs/heads/master HTTP/1.1 404 -
  45
  46###  getanyfile default
  47###
  48GET  /smart/repo.git/HEAD HTTP/1.1 200
  49GET  /smart/repo.git/info/refs HTTP/1.1 200
  50GET  /smart/repo.git/objects/info/packs HTTP/1.1 200
  51GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
  52GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  53GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200
  54GET  /smart/repo.git/$PACK_URL HTTP/1.1 200
  55GET  /smart/repo.git/$IDX_URL HTTP/1.1 200
  56
  57###  no git-daemon-export-ok
  58###
  59GET  /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
  60GET  /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
  61GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
  62GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
  63GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
  64GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
  65GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
  66GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
  67
  68###  git-daemon-export-ok
  69###
  70GET  /smart_noexport/repo.git/HEAD HTTP/1.1 200
  71GET  /smart_noexport/repo.git/info/refs HTTP/1.1 200
  72GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
  73GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
  74GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  75GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
  76GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
  77GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
  78
  79###  getanyfile true
  80###
  81GET  /smart/repo.git/HEAD HTTP/1.1 200
  82GET  /smart/repo.git/info/refs HTTP/1.1 200
  83GET  /smart/repo.git/objects/info/packs HTTP/1.1 200
  84GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
  85GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  86GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200
  87GET  /smart/repo.git/$PACK_URL HTTP/1.1 200
  88GET  /smart/repo.git/$IDX_URL HTTP/1.1 200
  89
  90###  getanyfile false
  91###
  92GET  /smart/repo.git/HEAD HTTP/1.1 403 -
  93GET  /smart/repo.git/info/refs HTTP/1.1 403 -
  94GET  /smart/repo.git/objects/info/packs HTTP/1.1 403 -
  95GET  /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
  96GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
  97GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
  98GET  /smart/repo.git/$PACK_URL HTTP/1.1 403 -
  99GET  /smart/repo.git/$IDX_URL HTTP/1.1 403 -
 100
 101###  uploadpack default
 102###
 103GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
 104POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
 105
 106###  uploadpack true
 107###
 108GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
 109POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
 110
 111###  uploadpack false
 112###
 113GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
 114POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
 115
 116###  receivepack default
 117###
 118GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
 119POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
 120
 121###  receivepack true
 122###
 123GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
 124POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
 125
 126###  receivepack false
 127###
 128GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
 129POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
 130EOF
 131test_expect_success 'server request log matches test results' '
 132        sed -e "
 133                s/^.* \"//
 134                s/\"//
 135                s/ [1-9][0-9]*\$//
 136                s/^GET /GET  /
 137        " >act <"$HTTPD_ROOT_PATH"/access.log &&
 138        test_cmp exp act
 139'
 140
 141stop_httpd
 142test_done