t5550: test display of remote http error messages
authorJeff King <peff@peff.net>
Thu, 22 May 2014 09:29:03 +0000 (05:29 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 May 2014 19:43:51 +0000 (12:43 -0700)
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>
t/lib-httpd.sh
t/lib-httpd/apache.conf
t/lib-httpd/error.sh [new file with mode: 0755]
t/t5550-http-fetch-dumb.sh
index 8e680efbf04dace3a503a2e788732d840dcf73ef..f7640bee9a4564f3099b0751811e7cd6a41ecc09 100644 (file)
@@ -113,6 +113,7 @@ prepare_httpd() {
        mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
        cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
        install_script broken-smart-http.sh
+       install_script error.sh
 
        ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
 
index 3a03e8263db7e1c632bf0552ec94ae6834de4bf9..b384d7993545365c17f3c8bded756b4e74faf794 100644 (file)
@@ -97,12 +97,16 @@ Alias /auth/dumb/ www/auth/dumb/
 </LocationMatch>
 ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
 ScriptAlias /broken_smart/ broken-smart-http.sh/
+ScriptAlias /error/ error.sh/
 <Directory ${GIT_EXEC_PATH}>
        Options FollowSymlinks
 </Directory>
 <Files broken-smart-http.sh>
        Options ExecCGI
 </Files>
+<Files error.sh>
+  Options ExecCGI
+</Files>
 <Files ${GIT_EXEC_PATH}/git-http-backend>
        Options ExecCGI
 </Files>
diff --git a/t/lib-httpd/error.sh b/t/lib-httpd/error.sh
new file mode 100755 (executable)
index 0000000..786f281
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+printf "Status: 500 Intentional Breakage\n"
+
+printf "Content-Type: "
+case "$PATH_INFO" in
+*html*)
+       printf "text/html"
+       ;;
+*text*)
+       printf "text/plain"
+       ;;
+esac
+printf "\n"
+
+printf "\n"
+printf "this is the error message\n"
index 1a3a2b6c1a20558a019143d1abbd2168af0caf53..13defd38866f4fff09b1dc607b2b8f64eaf733db 100755 (executable)
@@ -171,5 +171,15 @@ test_expect_success 'did not use upload-pack service' '
        test_cmp exp act
 '
 
+test_expect_success 'git client shows text/plain errors' '
+       test_must_fail git clone "$HTTPD_URL/error/text" 2>stderr &&
+       grep "this is the error message" stderr
+'
+
+test_expect_success 'git client does not show html errors' '
+       test_must_fail git clone "$HTTPD_URL/error/html" 2>stderr &&
+       ! grep "this is the error message" stderr
+'
+
 stop_httpd
 test_done