summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnatoly Burov <anatoly.rr@gmail.com>2016-09-07 14:09:45 +0300
committerTim Graham <timograham@gmail.com>2016-09-07 13:47:09 -0400
commit7b6dccc82fa5b03cf431742c0655e5ac954e228e (patch)
tree6c5eb5e7d4d0f30e475758258a794ec9bf13457b /tests
parent2b64ff68cc375b5688174b4087bf44be9edd2558 (diff)
Fixed #27191 -- Fixed debug view crash for requests with 'items' in GET/POST/COOKIES/FILES.
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_debug.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 714723c957..7a450306f5 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -464,6 +464,43 @@ class ExceptionReporterTests(SimpleTestCase):
html = reporter.get_traceback_html()
self.assertIn("http://evil.com/", html)
+ def test_request_with_items_key(self):
+ """
+ An exception report can be generated for requests with 'items' in
+ request GET, POST, FILES, or COOKIES QueryDicts.
+ """
+ if six.PY3:
+ value = '<td>items</td><td class="code"><pre>&#39;Oops&#39;</pre></td>'
+ else:
+ value = '<td>items</td><td class="code"><pre>u&#39;Oops&#39;</pre></td>'
+ # GET
+ request = self.rf.get('/test_view/?items=Oops')
+ reporter = ExceptionReporter(request, None, None, None)
+ html = reporter.get_traceback_html()
+ self.assertInHTML(value, html)
+ # POST
+ request = self.rf.post('/test_view/', data={'items': 'Oops'})
+ reporter = ExceptionReporter(request, None, None, None)
+ html = reporter.get_traceback_html()
+ self.assertInHTML(value, html)
+ # FILES
+ fp = six.StringIO('filecontent')
+ request = self.rf.post('/test_view/', data={'name': 'filename', 'items': fp})
+ reporter = ExceptionReporter(request, None, None, None)
+ html = reporter.get_traceback_html()
+ self.assertInHTML(
+ '<td>items</td><td class="code"><pre>&lt;InMemoryUploadedFile: '
+ 'items (application/octet-stream)&gt;</pre></td>',
+ html
+ )
+ # COOKES
+ rf = RequestFactory()
+ rf.cookies['items'] = 'Oops'
+ request = rf.get('/test_view/')
+ reporter = ExceptionReporter(request, None, None, None)
+ html = reporter.get_traceback_html()
+ self.assertInHTML('<td>items</td><td class="code"><pre>&#39;Oops&#39;</pre></td>', html)
+
class PlainTextReportTests(SimpleTestCase):
rf = RequestFactory()
@@ -519,6 +556,39 @@ class PlainTextReportTests(SimpleTestCase):
reporter = ExceptionReporter(request, None, "I'm a little teapot", None)
reporter.get_traceback_text()
+ def test_request_with_items_key(self):
+ """
+ An exception report can be generated for requests with 'items' in
+ request GET, POST, FILES, or COOKIES QueryDicts.
+ """
+ if six.PY3:
+ value = "items = 'Oops'"
+ else:
+ value = "items = u'Oops'"
+ # GET
+ request = self.rf.get('/test_view/?items=Oops')
+ reporter = ExceptionReporter(request, None, None, None)
+ text = reporter.get_traceback_text()
+ self.assertIn(value, text)
+ # POST
+ request = self.rf.post('/test_view/', data={'items': 'Oops'})
+ reporter = ExceptionReporter(request, None, None, None)
+ text = reporter.get_traceback_text()
+ self.assertIn(value, text)
+ # FILES
+ fp = six.StringIO('filecontent')
+ request = self.rf.post('/test_view/', data={'name': 'filename', 'items': fp})
+ reporter = ExceptionReporter(request, None, None, None)
+ text = reporter.get_traceback_text()
+ self.assertIn('items = <InMemoryUploadedFile:', text)
+ # COOKES
+ rf = RequestFactory()
+ rf.cookies['items'] = 'Oops'
+ request = rf.get('/test_view/')
+ reporter = ExceptionReporter(request, None, None, None)
+ text = reporter.get_traceback_text()
+ self.assertIn("items = 'Oops'", text)
+
def test_message_only(self):
reporter = ExceptionReporter(None, None, "I'm a little teapot", None)
reporter.get_traceback_text()