t5550: test display of remote http error messages

Since commit 426e70d (remote-curl: show server content on http errors, 2013-04-05), we relay any text/plain error messages from the remote server to the user. However, we never tested it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 22, 2014 at 05:29 UTC dbcf2bd3dec1244fdbafb3ec7312ed14d83c0025
4 files changed +32
t/lib-httpd.sh
+1
@@ -113,6 +113,7 @@ prepare_httpd() {
113 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
114 cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
115 install_script broken-smart-http.sh
116 + install_script error.sh
117
118 ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
119
t/lib-httpd/apache.conf
+4
@@ -97,12 +97,16 @@ Alias /auth/dumb/ www/auth/dumb/
97 </LocationMatch>
98 ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
99 ScriptAlias /broken_smart/ broken-smart-http.sh/
100 +ScriptAlias /error/ error.sh/
101 <Directory ${GIT_EXEC_PATH}>
102 Options FollowSymlinks
103 </Directory>
104 <Files broken-smart-http.sh>
105 Options ExecCGI
106 </Files>
107 +<Files error.sh>
108 + Options ExecCGI
109 +</Files>
110 <Files ${GIT_EXEC_PATH}/git-http-backend>
111 Options ExecCGI
112 </Files>
t/lib-httpd/error.sh new
+17
@@ -0,0 +1,17 @@
1 +#!/bin/sh
2 +
3 +printf "Status: 500 Intentional Breakage\n"
4 +
5 +printf "Content-Type: "
6 +case "$PATH_INFO" in
7 +*html*)
8 + printf "text/html"
9 + ;;
10 +*text*)
11 + printf "text/plain"
12 + ;;
13 +esac
14 +printf "\n"
15 +
16 +printf "\n"
17 +printf "this is the error message\n"
t/t5550-http-fetch-dumb.sh
+10
@@ -171,5 +171,15 @@ test_expect_success 'did not use upload-pack service' '
171 test_cmp exp act
172 '
173
174 +test_expect_success 'git client shows text/plain errors' '
175 + test_must_fail git clone "$HTTPD_URL/error/text" 2>stderr &&
176 + grep "this is the error message" stderr
177 +'
178 +
179 +test_expect_success 'git client does not show html errors' '
180 + test_must_fail git clone "$HTTPD_URL/error/html" 2>stderr &&
181 + ! grep "this is the error message" stderr
182 +'
183 +
184 stop_httpd
185 test_done