Skip to content

Commit dbcf2bd

Browse files
peffgitster
authored andcommitted
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>
1 parent c7db2d1 commit dbcf2bd

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

t/lib-httpd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ prepare_httpd() {
113113
mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
114114
cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
115115
install_script broken-smart-http.sh
116+
install_script error.sh
116117

117118
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
118119

t/lib-httpd/apache.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,16 @@ Alias /auth/dumb/ www/auth/dumb/
9797
</LocationMatch>
9898
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
9999
ScriptAlias /broken_smart/ broken-smart-http.sh/
100+
ScriptAlias /error/ error.sh/
100101
<Directory ${GIT_EXEC_PATH}>
101102
Options FollowSymlinks
102103
</Directory>
103104
<Files broken-smart-http.sh>
104105
Options ExecCGI
105106
</Files>
107+
<Files error.sh>
108+
Options ExecCGI
109+
</Files>
106110
<Files ${GIT_EXEC_PATH}/git-http-backend>
107111
Options ExecCGI
108112
</Files>

t/lib-httpd/error.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,15 @@ test_expect_success 'did not use upload-pack service' '
171171
test_cmp exp act
172172
'
173173

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+
174184
stop_httpd
175185
test_done

0 commit comments

Comments
 (0)