3 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
6 test_description
='test WebDAV http-push
8 This test runs various sanity checks on http-push.'
12 if git http-push
> /dev
/null
2>&1 ||
[ $?
-eq 128 ]
14 skip_all
="skipping test, USE_CURL_MULTI is not defined"
19 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5540'}
20 .
"$TEST_DIRECTORY"/lib-httpd.sh
24 test_expect_success
'setup remote repository' '
32 git commit -m initial &&
34 git clone --bare test_repo test_repo.git &&
36 git --bare update-server-info &&
37 mv hooks/post-update.sample hooks/post-update &&
38 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
43 test_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"
51 test_expect_success
'clone remote repository' '
53 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
56 test_expect_success
'push to remote repository with packed refs' '
57 cd "$ROOT_PATH"/test_repo_clone &&
61 git commit -m path2 &&
62 HEAD=$(git rev-parse --verify HEAD) &&
64 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
65 test $HEAD = $(git rev-parse --verify HEAD))
68 test_expect_success
'push already up-to-date' '
72 test_expect_success
'push to remote repository with unpacked refs' '
73 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
75 git update-ref refs/heads/master $ORIG_HEAD &&
76 git --bare update-server-info) &&
78 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
79 test $HEAD = $(git rev-parse --verify HEAD))
82 test_expect_success
'http-push fetches unpacked objects' '
83 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
84 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
86 git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
87 "$ROOT_PATH"/fetch_unpacked &&
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 &&
95 git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
98 test_expect_success
'http-push fetches packed objects' '
99 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
100 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
102 git clone $HTTPD_URL/dumb/test_repo_packed.git \
103 "$ROOT_PATH"/test_repo_clone_packed &&
105 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
107 git --bare prune-packed) &&
109 # By reset, we force git to retrieve the packed object
110 (cd "$ROOT_PATH"/test_repo_clone_packed &&
111 git reset --hard HEAD^ &&
112 git remote remove origin &&
113 git reflog expire --expire=0 --all &&
115 git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
118 test_expect_success
'create and delete remote branch' '
119 cd "$ROOT_PATH"/test_repo_clone &&
120 git checkout -b dev &&
125 git push origin dev &&
126 git push origin :dev &&
127 test_must_fail git show-ref --verify refs/remotes/origin/dev
130 test_expect_success
'MKCOL sends directory names with trailing slashes' '
132 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
139 x38
="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
142 test_expect_success
'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
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] "
152 test_http_push_nonff
"$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
153 "$ROOT_PATH"/test_repo_clone master
155 test_expect_success
'push to password-protected repository (user in URL)' '
156 test_commit pw-user &&
157 set_askpass user@host &&
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
165 test_expect_failure
'user was prompted only once for password' '
166 expect_askpass pass user@host
169 test_expect_failure
'push to password-protected repository (no user in URL)' '
170 test_commit pw-nouser &&
171 set_askpass user@host &&
172 git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
173 expect_askpass both user@host
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