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