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