From 11c5c581bb775f265a474337ef7051312c3bbd45 Mon Sep 17 00:00:00 2001 From: Brian Sutherland Date: Mon, 15 Apr 2013 12:17:22 +0200 Subject: [PATCH] test that .post headers don't leak between requests --- src/zope/testbrowser/tests/test_browser.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/zope/testbrowser/tests/test_browser.py b/src/zope/testbrowser/tests/test_browser.py index 6ce70f4..1ca30f1 100644 --- a/src/zope/testbrowser/tests/test_browser.py +++ b/src/zope/testbrowser/tests/test_browser.py @@ -875,6 +875,41 @@ def test_non_ascii_in_input_field(self): """ +def test_post_encoding_doesnt_leak_between_requests(self): + """ + >>> app = YetAnotherTestApp() + >>> browser = Browser(wsgi_app=app) + >>> body = b'''\ + ... + ...
+ ... + ... + ...
+ ... ''' + >>> app.add_response(b'json') + >>> app.add_response(body) + >>> app.add_response(b'done') + + Post some JSON + + >>> browser.post('http://localhost/', '1', 'application/json') + >>> browser.contents + 'json' + + then get a form and post it + + >>> browser.open('http://localhost/') + >>> browser.getControl("Do Stuff").click() + >>> browser.contents + 'done' + + The content_type of the last post should come from the form's enctype attr: + + >>> print(app.last_environ['CONTENT_TYPE']) + multipart/form-data +""" + + def test_suite(): return doctest.DocTestSuite( checker=zope.testbrowser.tests.helper.checker,