t5551: test server-side ERR packet
When a smart HTTP server sends an error message via pkt-line, we detect the error due to using PACKET_READ_DIE_ON_ERR_PACKET. This case was added by 2d103c31c2 (pack-protocol.txt: accept error packets in any context, 2018-12-29), but not covered by tests. Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Josh Steadmon committed
Feb 6, 2019 at 14:19 UTC
30dea56536e78ad8a9533d51ad1d8c9c85c3c7bd
4 files changed
+13
t/lib-httpd.sh
+1
@@ -131,6 +131,7 @@ prepare_httpd() {
131
mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
132
cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
133
install_script broken-smart-http.sh
134
+ install_script error-smart-http.sh
135
install_script error.sh
136
install_script apply-one-time-sed.sh
137
t/lib-httpd/apache.conf
+4
@@ -119,6 +119,7 @@ Alias /auth/dumb/ www/auth/dumb/
119
ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/
120
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
121
ScriptAlias /broken_smart/ broken-smart-http.sh/
122
+ScriptAlias /error_smart/ error-smart-http.sh/
123
ScriptAlias /error/ error.sh/
124
ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
125
<Directory ${GIT_EXEC_PATH}>
@@ -127,6 +128,9 @@ ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
128
<Files broken-smart-http.sh>
129
Options ExecCGI
130
</Files>
131
+<Files error-smart-http.sh>
132
+ Options ExecCGI
133
+</Files>
134
<Files error.sh>
135
Options ExecCGI
136
</Files>
t/lib-httpd/error-smart-http.sh
new
+3
@@ -0,0 +1,3 @@
1
+echo "Content-Type: application/x-git-upload-pack-advertisement"
2
+echo
3
+printf "%s" "0019ERR server-side error"
t/t5551-http-fetch-smart.sh
+5
@@ -429,5 +429,10 @@ test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' '
429
! grep "=> Send data" err
430
'
431
432
+test_expect_success 'server-side error detected' '
433
+ test_must_fail git clone $HTTPD_URL/error_smart/repo.git 2>actual &&
434
+ grep "server-side error" actual
435
+'
436
+
437
stop_httpd
438
test_done