diff options
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() |
