@matheusbsbs / matheus-bagliano / commits / 3cf8fe1d26
Fork 0

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 <gabriel.corona@enst-bretagne.fr> Acked-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Gabriel Corona committed Nov 14, 2010 at 02:51 UTC 3cf8fe1d26edd7c4cce6593d70212970f8b0bbc0
4 files changed +40
t/lib-httpd.sh
+3
@@ -75,12 +75,14 @@ fi
75
76 prepare_httpd() {
77 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
78 + cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
79
80 ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
81
82 if test -n "$LIB_HTTPD_SSL"
83 then
84 HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
85 + AUTH_HTTPD_URL=https://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
86
87 RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
88 -config "$TEST_PATH/ssl.cnf" \
@@ -92,6 +94,7 @@ prepare_httpd() {
94 HTTPD_PARA="$HTTPD_PARA -DSSL"
95 else
96 HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
97 + AUTH_HTTPD_URL=http://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
98 fi
99
100 if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
t/lib-httpd/apache.conf
+29
@@ -17,8 +17,30 @@ ErrorLog error.log
17 <IfModule !mod_env.c>
18 LoadModule env_module modules/mod_env.so
19 </IfModule>
20 +<IfModule !mod_version.c>
21 + LoadModule version_module modules/mod_version.so
22 +</IfModule>
23 +
24 +<IfVersion < 2.1>
25 +<IfModule !mod_auth.c>
26 + LoadModule auth_module modules/mod_auth.so
27 +</IfModule>
28 +</IfVersion>
29 +
30 +<IfVersion >= 2.1>
31 +<IfModule !mod_auth_basic.c>
32 + LoadModule auth_basic_module modules/mod_auth_basic.so
33 +</IfModule>
34 +<IfModule !mod_authn_file.c>
35 + LoadModule authn_file_module modules/mod_authn_file.so
36 +</IfModule>
37 +<IfModule !mod_authz_user.c>
38 + LoadModule authz_user_module modules/mod_authz_user.so
39 +</IfModule>
40 +</IfVersion>
41
42 Alias /dumb/ www/
43 +Alias /auth/ www/auth/
44
45 <Location /smart/>
46 SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
@@ -48,6 +70,13 @@ SSLMutex file:ssl_mutex
70 SSLEngine On
71 </IfDefine>
72
73 +<Location /auth/>
74 + AuthType Basic
75 + AuthName "git-auth"
76 + AuthUserFile passwd
77 + Require valid-user
78 +</Location>
79 +
80 <IfDefine DAV>
81 LoadModule dav_module modules/mod_dav.so
82 LoadModule dav_fs_module modules/mod_dav_fs.so
t/lib-httpd/passwd new
+1
@@ -0,0 +1 @@
1 +user@host:nKpa8pZUHx/ic
t/t5550-http-fetch.sh
+7
@@ -34,6 +34,13 @@ test_expect_success 'clone http repository' '
34 test_cmp file clone/file
35 '
36
37 +test_expect_failure 'clone http repository with authentication' '
38 + mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" &&
39 + cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" &&
40 + git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth &&
41 + test_cmp file clone-auth/file
42 +'
43 +
44 test_expect_success 'fetch changes via http' '
45 echo content >>file &&
46 git commit -a -m two &&