Skip to content

Commit

Permalink
test that .post headers don't leak between requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Sutherland committed Apr 15, 2013
1 parent 84bdeb2 commit 11c5c58
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/zope/testbrowser/tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''\
... <html><body>
... <form action="." method="POST" enctype="multipart/form-data">
... <input name="text.other-e" type="text" value="somedata"/>
... <button name="do" type="button">Do Stuff</button>
... </form></body></html>
... '''
>>> 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,
Expand Down

0 comments on commit 11c5c58

Please sign in to comment.