From: Gabriel Corona Date: Sun, 14 Nov 2010 01:51:14 +0000 (+0100) Subject: t5550: test HTTP authentication and userinfo decoding X-Git-Tag: v1.7.3.4~15^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3cf8fe1d26edd7c4cce6593d70212970f8b0bbc0;p=git.git t5550: test HTTP authentication and userinfo decoding Add a test for HTTP authentication and proper percent-decoding of the userinfo (username and password) part of the URL. Signed-off-by: Gabriel Corona Acked-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index e733f6516..3f2438437 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -75,12 +75,14 @@ fi prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" + cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" if test -n "$LIB_HTTPD_SSL" then HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT + AUTH_HTTPD_URL=https://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \ -config "$TEST_PATH/ssl.cnf" \ @@ -92,6 +94,7 @@ prepare_httpd() { HTTPD_PARA="$HTTPD_PARA -DSSL" else HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT + AUTH_HTTPD_URL=http://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT fi if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN" diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 4961505d1..b40e43bb3 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -17,8 +17,30 @@ ErrorLog error.log LoadModule env_module modules/mod_env.so + + LoadModule version_module modules/mod_version.so + + + + + LoadModule auth_module modules/mod_auth.so + + + += 2.1> + + LoadModule auth_basic_module modules/mod_auth_basic.so + + + LoadModule authn_file_module modules/mod_authn_file.so + + + LoadModule authz_user_module modules/mod_authz_user.so + + Alias /dumb/ www/ +Alias /auth/ www/auth/ SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} @@ -48,6 +70,13 @@ SSLMutex file:ssl_mutex SSLEngine On + + AuthType Basic + AuthName "git-auth" + AuthUserFile passwd + Require valid-user + + LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so diff --git a/t/lib-httpd/passwd b/t/lib-httpd/passwd new file mode 100644 index 000000000..f2fbcad33 --- /dev/null +++ b/t/lib-httpd/passwd @@ -0,0 +1 @@ +user@host:nKpa8pZUHx/ic diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh index 2fb48d09e..a0564deaa 100755 --- a/t/t5550-http-fetch.sh +++ b/t/t5550-http-fetch.sh @@ -34,6 +34,13 @@ test_expect_success 'clone http repository' ' test_cmp file clone/file ' +test_expect_failure 'clone http repository with authentication' ' + mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" && + cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" && + git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth && + test_cmp file clone-auth/file +' + test_expect_success 'fetch changes via http' ' echo content >>file && git commit -a -m two &&