diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/csrf_tests/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py index 7c1e62c504..8a9c509f4c 100644 --- a/tests/csrf_tests/tests.py +++ b/tests/csrf_tests/tests.py @@ -294,6 +294,19 @@ class CsrfViewMiddlewareTestMixin: status_code=403, ) + def test_https_malformed_host(self): + """ + CsrfViewMiddleware generates a 403 response if it receives an HTTPS + request with a bad host. + """ + req = self._get_GET_no_csrf_cookie_request() + req._is_secure_override = True + req.META['HTTP_HOST'] = '@malformed' + req.META['HTTP_REFERER'] = 'https://www.evil.org/somepage' + req.META['SERVER_PORT'] = '443' + response = self.mw.process_view(req, token_view, (), {}) + self.assertEqual(response.status_code, 403) + @override_settings(DEBUG=True) def test_https_malformed_referer(self): """ |
