blob: 11b343274ff36247f45de6eefbdbebce511915be [file] [log] [blame]
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +01001#!/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
14
Mike Hommey96086262008-07-07 21:02:50 +020015if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
16then
17 say "skipping test, USE_CURL_MULTI is not defined"
18 test_done
19 exit
20fi
21
Junio C Hamanobfdbee92008-08-08 02:26:28 -070022. "$TEST_DIRECTORY"/lib-httpd.sh
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010023
24if ! start_httpd >&3 2>&4
25then
26 say "skipping test, web server setup failed"
27 test_done
28 exit
29fi
30
31test_expect_success 'setup remote repository' '
32 cd "$ROOT_PATH" &&
33 mkdir test_repo &&
34 cd test_repo &&
35 git init &&
36 : >path1 &&
37 git add path1 &&
38 test_tick &&
39 git commit -m initial &&
40 cd - &&
41 git clone --bare test_repo test_repo.git &&
42 cd test_repo.git &&
43 git --bare update-server-info &&
Petr Baudis7dce9912008-08-12 00:34:46 +020044 mv hooks/post-update.sample hooks/post-update &&
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010045 cd - &&
Mike Hommey13b54812008-07-07 21:02:37 +020046 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010047'
Jeff King3b2eb182008-06-14 03:25:56 -040048
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010049test_expect_success 'clone remote repository' '
50 cd "$ROOT_PATH" &&
51 git clone $HTTPD_URL/test_repo.git test_repo_clone
52'
53
Johannes Schindelin8ee09ac2009-01-17 16:41:41 +010054test_expect_failure 'push to remote repository with packed refs' '
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010055 cd "$ROOT_PATH"/test_repo_clone &&
56 : >path2 &&
57 git add path2 &&
58 test_tick &&
59 git commit -m path2 &&
Johannes Schindelin8ee09ac2009-01-17 16:41:41 +010060 HEAD=$(git rev-parse --verify HEAD) &&
Mike Hommeyb5cd2d12008-07-07 23:06:46 +020061 git push &&
Johannes Schindelin8ee09ac2009-01-17 16:41:41 +010062 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
63 test $HEAD = $(git rev-parse --verify HEAD))
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010064'
65
Johannes Schindelin8ee09ac2009-01-17 16:41:41 +010066test_expect_success ' push to remote repository with unpacked refs' '
67 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
68 rm packed-refs &&
69 git update-ref refs/heads/master \
70 0c973ae9bd51902a28466f3850b543fa66a6aaf4) &&
71 git push &&
72 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
73 test $HEAD = $(git rev-parse --verify HEAD))
74'
75
76test_expect_success 'create and delete remote branch' '
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010077 cd "$ROOT_PATH"/test_repo_clone &&
78 git checkout -b dev &&
79 : >path3 &&
80 git add path3 &&
81 test_tick &&
82 git commit -m dev &&
83 git push origin dev &&
84 git fetch &&
85 git push origin :dev &&
86 git branch -d -r origin/dev &&
87 git fetch &&
Stephan Beyerd492b312008-07-12 17:47:52 +020088 test_must_fail git show-ref --verify refs/remotes/origin/dev
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +010089'
90
Johannes Schindelin466ddf92009-01-17 16:11:51 +010091test_expect_success 'MKCOL sends directory names with trailing slashes' '
92
93 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
94
95'
96
Tay Ray Chuandfab7c12009-02-14 17:52:14 +080097test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
98
99 grep -P "\"(?:PUT|MOVE) .+objects/[\da-z]{2}/[\da-z]{38}_[\da-z\-]{40} HTTP/[0-9.]+\" 20\d" \
100 < "$HTTPD_ROOT_PATH"/access.log
101
102'
103
Clemens Buchacherfaa4bc32008-02-27 20:28:45 +0100104stop_httpd
105
106test_done