diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2021-04-29 14:35:11 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-04-30 08:05:42 +0200 |
| commit | 8bcb00858e0ddec79cc96669c238d29c30d7effb (patch) | |
| tree | cba5b4df1cd188543adc523ccedfead1ac26075d /tests | |
| parent | ca34db46504fca1221e27f6ab13734dfdfde6e1c (diff) | |
Fixed #32698 -- Moved HttpRequest.get_raw_uri() to ExceptionReporter._get_raw_insecure_uri().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/requests/tests.py | 12 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 14 |
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/requests/tests.py b/tests/requests/tests.py index c57d5caae2..3d8bb45b00 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -558,18 +558,6 @@ class RequestsTests(SimpleTestCase): with self.assertRaises(UnreadablePostError): request.FILES - @override_settings(ALLOWED_HOSTS=['example.com']) - def test_get_raw_uri(self): - factory = RequestFactory(HTTP_HOST='evil.com') - request = factory.get('////absolute-uri') - self.assertEqual(request.get_raw_uri(), 'http://evil.com//absolute-uri') - - request = factory.get('/?foo=bar') - self.assertEqual(request.get_raw_uri(), 'http://evil.com/?foo=bar') - - request = factory.get('/path/with:colons') - self.assertEqual(request.get_raw_uri(), 'http://evil.com/path/with:colons') - class HostValidationTests(SimpleTestCase): poisoned_hosts = [ 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() |
