]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5540-http-push.sh
Git 1.8.5
[thirdparty/git.git] / t / t5540-http-push.sh
CommitLineData
faa4bc35
CB
1#!/bin/sh
2#
3# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
4#
5
7da4e228 6test_description='test WebDAV http-push
faa4bc35
CB
7
8This test runs various sanity checks on http-push.'
9
10. ./test-lib.sh
11
96086262
MH
12if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
13then
fadb5156 14 skip_all="skipping test, USE_CURL_MULTI is not defined"
96086262 15 test_done
96086262
MH
16fi
17
859d1fb4
CB
18LIB_HTTPD_DAV=t
19LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
bfdbee98 20. "$TEST_DIRECTORY"/lib-httpd.sh
859d1fb4 21ROOT_PATH="$PWD"
75318a3b 22start_httpd
faa4bc35
CB
23
24test_expect_success 'setup remote repository' '
25 cd "$ROOT_PATH" &&
26 mkdir test_repo &&
27 cd test_repo &&
28 git init &&
29 : >path1 &&
30 git add path1 &&
31 test_tick &&
32 git commit -m initial &&
33 cd - &&
34 git clone --bare test_repo test_repo.git &&
35 cd test_repo.git &&
36 git --bare update-server-info &&
7dce9918 37 mv hooks/post-update.sample hooks/post-update &&
ae4efe19 38 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
faa4bc35 39 cd - &&
13b5481e 40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
faa4bc35 41'
3b2eb186 42
0521710a
JK
43test_expect_success 'create password-protected repository' '
44 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
45 cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
46 "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
47'
48
e837936c 49setup_askpass_helper
0521710a 50
faa4bc35
CB
51test_expect_success 'clone remote repository' '
52 cd "$ROOT_PATH" &&
024bb125 53 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
faa4bc35
CB
54'
55
ae4efe19 56test_expect_success 'push to remote repository with packed refs' '
faa4bc35
CB
57 cd "$ROOT_PATH"/test_repo_clone &&
58 : >path2 &&
59 git add path2 &&
60 test_tick &&
61 git commit -m path2 &&
8ee09acd 62 HEAD=$(git rev-parse --verify HEAD) &&
b5cd2d1e 63 git push &&
8ee09acd
JS
64 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
65 test $HEAD = $(git rev-parse --verify HEAD))
faa4bc35
CB
66'
67
d8f67d20 68test_expect_success 'push already up-to-date' '
ae4efe19
SP
69 git push
70'
71
72test_expect_success 'push to remote repository with unpacked refs' '
8ee09acd
JS
73 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
74 rm packed-refs &&
ae4efe19
SP
75 git update-ref refs/heads/master $ORIG_HEAD &&
76 git --bare update-server-info) &&
8ee09acd
JS
77 git push &&
78 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
79 test $HEAD = $(git rev-parse --verify HEAD))
80'
81
4f66250d 82test_expect_success 'http-push fetches unpacked objects' '
242a9077
TRC
83 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
84 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
85
024bb125 86 git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
242a9077
TRC
87 "$ROOT_PATH"/fetch_unpacked &&
88
89 # By reset, we force git to retrieve the object
90 (cd "$ROOT_PATH"/fetch_unpacked &&
91 git reset --hard HEAD^ &&
92 git remote rm origin &&
93 git reflog expire --expire=0 --all &&
94 git prune &&
024bb125 95 git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
242a9077
TRC
96'
97
4f66250d 98test_expect_success 'http-push fetches packed objects' '
86d99f6d
TRC
99 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
100 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
101
024bb125 102 git clone $HTTPD_URL/dumb/test_repo_packed.git \
86d99f6d
TRC
103 "$ROOT_PATH"/test_repo_clone_packed &&
104
105 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
106 git --bare repack &&
107 git --bare prune-packed) &&
108
109 # By reset, we force git to retrieve the packed object
110 (cd "$ROOT_PATH"/test_repo_clone_packed &&
111 git reset --hard HEAD^ &&
e17dba8f 112 git remote remove origin &&
86d99f6d
TRC
113 git reflog expire --expire=0 --all &&
114 git prune &&
024bb125 115 git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
86d99f6d
TRC
116'
117
8ee09acd 118test_expect_success 'create and delete remote branch' '
faa4bc35
CB
119 cd "$ROOT_PATH"/test_repo_clone &&
120 git checkout -b dev &&
121 : >path3 &&
122 git add path3 &&
123 test_tick &&
124 git commit -m dev &&
125 git push origin dev &&
faa4bc35 126 git push origin :dev &&
d492b31c 127 test_must_fail git show-ref --verify refs/remotes/origin/dev
faa4bc35
CB
128'
129
466ddf90
JS
130test_expect_success 'MKCOL sends directory names with trailing slashes' '
131
132 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
133
134'
135
2591838b
JS
136x1="[0-9a-f]"
137x2="$x1$x1"
138x5="$x1$x1$x1$x1$x1"
139x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
140x40="$x38$x2"
dfab7c14 141
2591838b 142test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
f6918da7
BG
143 sed \
144 -e "s/PUT /OP /" \
145 -e "s/MOVE /OP /" \
146 -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \
147 "$HTTPD_ROOT_PATH"/access.log |
148 grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] "
dfab7c14
TRC
149
150'
151
6cbd6e92
TRC
152test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
153 "$ROOT_PATH"/test_repo_clone master
154
a4ddbc33 155test_expect_success 'push to password-protected repository (user in URL)' '
0521710a 156 test_commit pw-user &&
e837936c 157 set_askpass user@host &&
0521710a
JK
158 git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
159 git rev-parse --verify HEAD >expect &&
160 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
161 rev-parse --verify HEAD >actual &&
162 test_cmp expect actual
163'
164
e837936c
JK
165test_expect_failure 'user was prompted only once for password' '
166 expect_askpass pass user@host
167'
168
0521710a
JK
169test_expect_failure 'push to password-protected repository (no user in URL)' '
170 test_commit pw-nouser &&
e837936c 171 set_askpass user@host &&
0521710a 172 git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
e837936c 173 expect_askpass both user@host
0521710a
JK
174 git rev-parse --verify HEAD >expect &&
175 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
176 rev-parse --verify HEAD >actual &&
177 test_cmp expect actual
178'
179
faa4bc35
CB
180stop_httpd
181
182test_done