summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xmlrpc.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-12-06 01:36:07 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-12-06 01:36:07 (GMT)
commit7eda940e1f693ea419a07713fe1db9d07cbf92d0 (patch)
treefc83b904ce72d6e9805f5205c3e43de693a8be62 /Lib/test/test_xmlrpc.py
parent3a12282ace47bd7704a875b1412212a8d83e0b2d (diff)
parenteca72d47f5a639a0ac66a98a2d63b30df2ce310f (diff)
downloadcpython-7eda940e1f693ea419a07713fe1db9d07cbf92d0.zip
cpython-7eda940e1f693ea419a07713fe1db9d07cbf92d0.tar.gz
cpython-7eda940e1f693ea419a07713fe1db9d07cbf92d0.tar.bz2
merge 3.4 (#16043)
Diffstat (limited to 'Lib/test/test_xmlrpc.py')
-rw-r--r--Lib/test/test_xmlrpc.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index b05198d..079f52c 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -880,7 +880,7 @@ class GzipServerTestCase(BaseServerTestCase):
p.pow(6, 8)
p("close")()
- def test_gsip_response(self):
+ def test_gzip_response(self):
t = self.Transport()
p = xmlrpclib.ServerProxy(URL, transport=t)
old = self.requestHandler.encode_threshold
@@ -894,6 +894,27 @@ class GzipServerTestCase(BaseServerTestCase):
self.requestHandler.encode_threshold = old
self.assertTrue(a>b)
+
+@unittest.skipIf(gzip is None, 'requires gzip')
+class GzipUtilTestCase(unittest.TestCase):
+
+ def test_gzip_decode_limit(self):
+ max_gzip_decode = 20 * 1024 * 1024
+ data = b'\0' * max_gzip_decode
+ encoded = xmlrpclib.gzip_encode(data)
+ decoded = xmlrpclib.gzip_decode(encoded)
+ self.assertEqual(len(decoded), max_gzip_decode)
+
+ data = b'\0' * (max_gzip_decode + 1)
+ encoded = xmlrpclib.gzip_encode(data)
+
+ with self.assertRaisesRegexp(ValueError,
+ "max gzipped payload length exceeded"):
+ xmlrpclib.gzip_decode(encoded)
+
+ xmlrpclib.gzip_decode(encoded, max_decode=-1)
+
+
#Test special attributes of the ServerProxy object
class ServerProxyTestCase(unittest.TestCase):
def setUp(self):
@@ -1123,7 +1144,7 @@ def test_main():
support.run_unittest(XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
BinaryTestCase, FaultTestCase, UseBuiltinTypesTestCase,
SimpleServerTestCase, KeepaliveServerTestCase1,
- KeepaliveServerTestCase2, GzipServerTestCase,
+ KeepaliveServerTestCase2, GzipServerTestCase, GzipUtilTestCase,
MultiPathServerTestCase, ServerProxyTestCase, FailingServerTestCase,
CGIHandlerTestCase)