git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "Kyle J. McKay" <mackyle@gmail.com>
Subject: [PATCH 6/9] t5550: test display of remote http error messages
Date: Wed, 21 May 2014 06:29:55 -0400	[thread overview]
Message-ID: <20140521102955.GF30464@sigill.intra.peff.net> (raw)
In-Reply-To: <20140521102524.GA30301@sigill.intra.peff.net>

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>
---
 t/lib-httpd.sh             |  1 +
 t/lib-httpd/apache.conf    |  4 ++++
 t/lib-httpd/error.sh       | 17 +++++++++++++++++
 t/t5550-http-fetch-dumb.sh | 10 ++++++++++
 4 files changed, 32 insertions(+)
 create mode 100755 t/lib-httpd/error.sh

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 8e680ef..f7640be 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -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"
 
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 3a03e82..b384d79 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -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
index 0000000..786f281
--- /dev/null
+++ b/t/lib-httpd/error.sh
@@ -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"
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 1a3a2b6..13defd3 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -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
-- 
2.0.0.rc1.436.g03cb729

  parent reply	other threads:[~2014-05-21 10:30 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 10:25 [PATCH 0/9] handle alternate charsets for remote http errors Jeff King
2014-05-21 10:27 ` [PATCH 1/9] test-lib: preserve GIT_CURL_VERBOSE from the environment Jeff King
2014-05-21 10:27 ` [PATCH 2/9] strbuf: add strbuf_tolower function Jeff King
2014-05-22  0:07   ` Kyle J. McKay
2014-05-22  5:58     ` Jeff King
2014-05-22 18:36       ` Junio C Hamano
2014-05-22 18:41         ` Jeff King
2014-05-22 21:04           ` Junio C Hamano
2014-05-23 20:03             ` Jeff King
2014-05-22 22:52           ` Kyle J. McKay
2014-05-23 20:05             ` Jeff King
2014-05-23 22:34               ` Kyle J. McKay
2014-05-21 10:28 ` [PATCH 3/9] daemon/config: factor out duplicate xstrdup_tolower Jeff King
2014-05-21 10:29 ` [PATCH 4/9] http: normalize case of returned content-type Jeff King
2014-05-21 10:29 ` [PATCH 5/9] t/lib-httpd: use write_script to copy CGI scripts Jeff King
2014-05-21 10:29 ` Jeff King [this message]
2014-05-21 10:33 ` [PATCH 7/9] remote-curl: recognize text/plain with a charset parameter Jeff King
2014-05-22  0:07   ` Kyle J. McKay
2014-05-22  6:05     ` Jeff King
2014-05-22  7:27       ` Kyle J. McKay
2014-05-22  9:02         ` Jeff King
2014-05-22  7:12     ` Peter Krefting
2014-05-22  9:05       ` Jeff King
2014-05-22 10:19         ` Peter Krefting
2014-05-21 10:33 ` [PATCH 8/9] strbuf: add strbuf_reencode helper Jeff King
2014-05-21 10:33 ` [PATCH 9/9] remote-curl: reencode http error messages Jeff King
2014-05-22  0:07   ` Kyle J. McKay
2014-05-22  6:05     ` Jeff King
2014-05-22  7:26     ` Peter Krefting
2014-05-22  9:28 ` [PATCH v2 0/9] handle alternate charsets for remote http errors Jeff King
2014-05-22  9:28   ` [PATCH v2 1/8] test-lib: preserve GIT_CURL_VERBOSE from the environment Jeff King
2014-05-22  9:28   ` [PATCH v2 2/8] t/lib-httpd: use write_script to copy CGI scripts Jeff King
2014-05-22  9:29   ` [PATCH v2 3/8] t5550: test display of remote http error messages Jeff King
2014-05-22  9:29   ` [PATCH v2 4/8] http: extract type/subtype portion of content-type Jeff King
2014-05-22 22:52     ` Kyle J. McKay
2014-05-23 20:12       ` Jeff King
2014-05-23 22:00         ` Kyle J. McKay
2014-05-22  9:30   ` [PATCH v2 5/8] http: optionally extract charset parameter from content-type Jeff King
2014-05-22  9:30   ` [PATCH v2 6/8] strbuf: add strbuf_reencode helper Jeff King
2014-05-22  9:30   ` [PATCH v2 7/8] remote-curl: reencode http error messages Jeff King
2014-05-22  9:36   ` [PATCH v2 8/8] http: default text charset to iso-8859-1 Jeff King
2014-05-23  2:02     ` brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140521102955.GF30464@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=mackyle@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).