Skip to content

Commit 0521710

Browse files
peffgitster
authored andcommitted
t5540: test DAV push with authentication
We don't currently test this case at all, and instead just test the DAV mechanism over an unauthenticated push. That isn't very realistic, as most people will want to authenticate pushes. Two of the tests expect_failure as they reveal bugs: 1. Pushing without a username in the URL fails to ask for credentials when we get an HTTP 401. This has always been the case, but it would be nice if it worked like smart-http. 2. Pushing with a username fails to ask for the password since 986bbc0 (http: don't always prompt for password, 2011-11-04). This is a severe regression in v1.7.8, as authenticated push-over-DAV is now totally unusable unless you have credentials in your .netrc. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 10dd3b2 commit 0521710

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

t/lib-httpd/apache.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ SSLEngine On
9292
<Location /dumb/>
9393
Dav on
9494
</Location>
95+
<Location /auth/dumb>
96+
Dav on
97+
</Location>
9598
</IfDefine>
9699

97100
<IfDefine SVN>

t/t5540-http-push.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ test_expect_success 'setup remote repository' '
4040
mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
4141
'
4242

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"
47+
'
48+
49+
test_expect_success 'setup askpass helper' '
50+
cat >askpass <<-\EOF &&
51+
#!/bin/sh
52+
echo user@host
53+
EOF
54+
chmod +x askpass &&
55+
GIT_ASKPASS="$PWD/askpass" &&
56+
export GIT_ASKPASS
57+
'
58+
4359
test_expect_success 'clone remote repository' '
4460
cd "$ROOT_PATH" &&
4561
git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
@@ -144,6 +160,24 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
144160
test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
145161
"$ROOT_PATH"/test_repo_clone master
146162

163+
test_expect_failure 'push to password-protected repository (user in URL)' '
164+
test_commit pw-user &&
165+
git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
166+
git rev-parse --verify HEAD >expect &&
167+
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
168+
rev-parse --verify HEAD >actual &&
169+
test_cmp expect actual
170+
'
171+
172+
test_expect_failure 'push to password-protected repository (no user in URL)' '
173+
test_commit pw-nouser &&
174+
git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
175+
git rev-parse --verify HEAD >expect &&
176+
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
177+
rev-parse --verify HEAD >actual &&
178+
test_cmp expect actual
179+
'
180+
147181
stop_httpd
148182

149183
test_done

0 commit comments

Comments
 (0)