t / t5561-http-backend.shon commit Merge branch 'en/merge-fixes' (10b8084)
   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
  32. "$TEST_DIRECTORY"/t556x_common
  33
  34grep '^[^#]' >exp <<EOF
  35
  36###  refs/heads/master
  37###
  38GET  /smart/repo.git/refs/heads/master HTTP/1.1 404 -
  39
  40###  getanyfile default
  41###
  42GET  /smart/repo.git/HEAD HTTP/1.1 200
  43GET  /smart/repo.git/info/refs HTTP/1.1 200
  44GET  /smart/repo.git/objects/info/packs HTTP/1.1 200
  45GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
  46GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  47GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200
  48GET  /smart/repo.git/$PACK_URL HTTP/1.1 200
  49GET  /smart/repo.git/$IDX_URL HTTP/1.1 200
  50
  51###  no git-daemon-export-ok
  52###
  53GET  /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
  54GET  /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
  55GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
  56GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
  57GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
  58GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
  59GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
  60GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
  61
  62###  git-daemon-export-ok
  63###
  64GET  /smart_noexport/repo.git/HEAD HTTP/1.1 200
  65GET  /smart_noexport/repo.git/info/refs HTTP/1.1 200
  66GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
  67GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
  68GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  69GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
  70GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
  71GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
  72
  73###  getanyfile true
  74###
  75GET  /smart/repo.git/HEAD HTTP/1.1 200
  76GET  /smart/repo.git/info/refs HTTP/1.1 200
  77GET  /smart/repo.git/objects/info/packs HTTP/1.1 200
  78GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
  79GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
  80GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200
  81GET  /smart/repo.git/$PACK_URL HTTP/1.1 200
  82GET  /smart/repo.git/$IDX_URL HTTP/1.1 200
  83
  84###  getanyfile false
  85###
  86GET  /smart/repo.git/HEAD HTTP/1.1 403 -
  87GET  /smart/repo.git/info/refs HTTP/1.1 403 -
  88GET  /smart/repo.git/objects/info/packs HTTP/1.1 403 -
  89GET  /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
  90GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
  91GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
  92GET  /smart/repo.git/$PACK_URL HTTP/1.1 403 -
  93GET  /smart/repo.git/$IDX_URL HTTP/1.1 403 -
  94
  95###  uploadpack default
  96###
  97GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
  98POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
  99
 100###  uploadpack true
 101###
 102GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
 103POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
 104
 105###  uploadpack false
 106###
 107GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
 108POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
 109
 110###  receivepack default
 111###
 112GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
 113POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
 114
 115###  receivepack true
 116###
 117GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
 118POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
 119
 120###  receivepack false
 121###
 122GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
 123POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
 124EOF
 125test_expect_success 'server request log matches test results' '
 126        sed -e "
 127                s/^.* \"//
 128                s/\"//
 129                s/ [1-9][0-9]*\$//
 130                s/^GET /GET  /
 131        " >act <"$HTTPD_ROOT_PATH"/access.log &&
 132        test_cmp exp act
 133'
 134
 135stop_httpd
 136test_done