From ede6f8035ab06ba3c1246127e42fe4155aa4e83f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 11 Nov 2015 13:44:43 +0100 Subject: [PATCH] Show public_msg on PublishError error page (#8944) --- tests/test_publisher.py | 26 ++++++++++++++++++++++++++ wcs/qommon/errors.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/test_publisher.py b/tests/test_publisher.py index 1517c49..5384fa4 100644 --- a/tests/test_publisher.py +++ b/tests/test_publisher.py @@ -1,6 +1,7 @@ import re import sys import shutil +import StringIO from quixote import cleanup from wcs.qommon.http_request import HTTPRequest @@ -74,3 +75,28 @@ def test_finish_failed_request(): body = pub.finish_failed_request() assert 'Traceback (most recent call last)' in str(body) assert '
' in str(body) + +def test_finish_interrupted_request(): + req = HTTPRequest(StringIO.StringIO(''), { + 'SERVER_NAME': 'www.example.net', + 'SCRIPT_NAME': '', + 'CONTENT_LENGTH': 'aaa', + }) + response = pub.process_request(req) + assert 'invalid content-length header' in response.body + req = HTTPRequest(StringIO.StringIO(''), { + 'SERVER_NAME': 'www.example.net', + 'SCRIPT_NAME': '', + 'CONTENT_TYPE': 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH': '1', + }) + response = pub.process_request(req) + assert 'Invalid request: unexpected end of request body' in response.body + req = HTTPRequest(StringIO.StringIO(''), { + 'SERVER_NAME': 'www.example.net', + 'SCRIPT_NAME': '', + 'CONTENT_TYPE': 'multipart/form-data', + 'CONTENT_LENGTH': '1', + }) + response = pub.process_request(req) + assert 'Invalid request: multipart/form-data missing boundary' in response.body diff --git a/wcs/qommon/errors.py b/wcs/qommon/errors.py index 4bd0011..592a668 100644 --- a/wcs/qommon/errors.py +++ b/wcs/qommon/errors.py @@ -113,4 +113,4 @@ TraversalError.description = N_( def format_publish_error(exc): - return template.error_page(_(exc.description), _(exc.title)) + return template.error_page(exc.format(), _(exc.title)) -- 2.1.4