t: test http access to "half-auth" repositories

Some sites set up http access to repositories such that fetching is anonymous and unauthenticated, but pushing is authenticated. While there are multiple ways to do this, the technique advertised in the git-http-backend manpage is to block access to locations matching "/git-receive-pack$". Let's emulate that advice in our test setup, which makes it clear that this advice does not actually work. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 27, 2012 at 09:25 UTC 4c71009da60baee436358e84ff1057cd1c80e776
3 files changed +28
t/lib-httpd/apache.conf
+7
@@ -89,6 +89,13 @@ SSLEngine On
89 Require valid-user
90 </Location>
91
92 +<LocationMatch "^/auth-push/.*/git-receive-pack$">
93 + AuthType Basic
94 + AuthName "git-auth"
95 + AuthUserFile passwd
96 + Require valid-user
97 +</LocationMatch>
98 +
99 <IfDefine DAV>
100 LoadModule dav_module modules/mod_dav.so
101 LoadModule dav_fs_module modules/mod_dav_fs.so
t/t5541-http-push.sh
+12
@@ -280,5 +280,17 @@ test_expect_success 'push over smart http with auth' '
280 test_cmp expect actual
281 '
282
283 +test_expect_failure 'push to auth-only-for-push repo' '
284 + cd "$ROOT_PATH/test_repo_clone" &&
285 + echo push-half-auth >expect &&
286 + test_commit push-half-auth &&
287 + set_askpass user@host &&
288 + git push "$HTTPD_URL"/auth-push/smart/test_repo.git &&
289 + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
290 + log -1 --format=%s >actual &&
291 + expect_askpass both user@host &&
292 + test_cmp expect actual
293 +'
294 +
295 stop_httpd
296 test_done
t/t5551-http-fetch.sh
+9
@@ -120,6 +120,15 @@ test_expect_success 'clone from password-protected repository' '
120 test_cmp expect actual
121 '
122
123 +test_expect_success 'clone from auth-only-for-push repository' '
124 + echo two >expect &&
125 + set_askpass wrong &&
126 + git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth &&
127 + expect_askpass none &&
128 + git --git-dir=smart-noauth log -1 --format=%s >actual &&
129 + test_cmp expect actual
130 +'
131 +
132 test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
133
134 test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '