summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-04-29 14:35:11 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-30 08:05:42 +0200
commit8bcb00858e0ddec79cc96669c238d29c30d7effb (patch)
treecba5b4df1cd188543adc523ccedfead1ac26075d /tests/view_tests
parentca34db46504fca1221e27f6ab13734dfdfde6e1c (diff)
downloaddjango-8bcb00858e0ddec79cc96669c238d29c30d7effb.tar.gz
Fixed #32698 -- Moved HttpRequest.get_raw_uri() to ExceptionReporter._get_raw_insecure_uri().
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_debug.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 9c85ed20fc..c8cc4aeb1e 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -942,6 +942,20 @@ class ExceptionReporterTests(SimpleTestCase):
reporter.get_traceback_text()
m.assert_called_once_with(encoding='utf-8')
+ @override_settings(ALLOWED_HOSTS=['example.com'])
+ def test_get_raw_insecure_uri(self):
+ factory = RequestFactory(HTTP_HOST='evil.com')
+ tests = [
+ ('////absolute-uri', 'http://evil.com//absolute-uri'),
+ ('/?foo=bar', 'http://evil.com/?foo=bar'),
+ ('/path/with:colons', 'http://evil.com/path/with:colons'),
+ ]
+ for url, expected in tests:
+ with self.subTest(url=url):
+ request = factory.get(url)
+ reporter = ExceptionReporter(request, None, None, None)
+ self.assertEqual(reporter._get_raw_insecure_uri(), expected)
+
class PlainTextReportTests(SimpleTestCase):
rf = RequestFactory()