t / t5540-http-push.shon commit add basic http clone/fetch tests (119c8ee)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
   4#
   5
   6test_description='test http-push
   7
   8This test runs various sanity checks on http-push.'
   9
  10. ./test-lib.sh
  11
  12ROOT_PATH="$PWD"
  13LIB_HTTPD_DAV=t
  14LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
  15
  16if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
  17then
  18        say "skipping test, USE_CURL_MULTI is not defined"
  19        test_done
  20        exit
  21fi
  22
  23. "$TEST_DIRECTORY"/lib-httpd.sh
  24start_httpd
  25
  26test_expect_success 'setup remote repository' '
  27        cd "$ROOT_PATH" &&
  28        mkdir test_repo &&
  29        cd test_repo &&
  30        git init &&
  31        : >path1 &&
  32        git add path1 &&
  33        test_tick &&
  34        git commit -m initial &&
  35        cd - &&
  36        git clone --bare test_repo test_repo.git &&
  37        cd test_repo.git &&
  38        git --bare update-server-info &&
  39        mv hooks/post-update.sample hooks/post-update &&
  40        cd - &&
  41        mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
  42'
  43
  44test_expect_success 'clone remote repository' '
  45        cd "$ROOT_PATH" &&
  46        git clone $HTTPD_URL/test_repo.git test_repo_clone
  47'
  48
  49test_expect_failure 'push to remote repository with packed refs' '
  50        cd "$ROOT_PATH"/test_repo_clone &&
  51        : >path2 &&
  52        git add path2 &&
  53        test_tick &&
  54        git commit -m path2 &&
  55        HEAD=$(git rev-parse --verify HEAD) &&
  56        git push &&
  57        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  58         test $HEAD = $(git rev-parse --verify HEAD))
  59'
  60
  61test_expect_success ' push to remote repository with unpacked refs' '
  62        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  63         rm packed-refs &&
  64         git update-ref refs/heads/master \
  65                0c973ae9bd51902a28466f3850b543fa66a6aaf4) &&
  66        git push &&
  67        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
  68         test $HEAD = $(git rev-parse --verify HEAD))
  69'
  70
  71test_expect_success 'create and delete remote branch' '
  72        cd "$ROOT_PATH"/test_repo_clone &&
  73        git checkout -b dev &&
  74        : >path3 &&
  75        git add path3 &&
  76        test_tick &&
  77        git commit -m dev &&
  78        git push origin dev &&
  79        git fetch &&
  80        git push origin :dev &&
  81        git branch -d -r origin/dev &&
  82        git fetch &&
  83        test_must_fail git show-ref --verify refs/remotes/origin/dev
  84'
  85
  86test_expect_success 'MKCOL sends directory names with trailing slashes' '
  87
  88        ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
  89
  90'
  91
  92test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
  93
  94        grep -P "\"(?:PUT|MOVE) .+objects/[\da-z]{2}/[\da-z]{38}_[\da-z\-]{40} HTTP/[0-9.]+\" 20\d" \
  95                < "$HTTPD_ROOT_PATH"/access.log
  96
  97'
  98
  99stop_httpd
 100
 101test_done