mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #25017 -- Allowed customizing the DISALLOWED_USER_AGENTS response
This commit is contained in:
@@ -9,6 +9,7 @@ from unittest import skipIf
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import (
|
||||
FileResponse, HttpRequest, HttpResponse, HttpResponsePermanentRedirect,
|
||||
HttpResponseRedirect, StreamingHttpResponse,
|
||||
@@ -256,9 +257,8 @@ class CommonMiddlewareTest(SimpleTestCase):
|
||||
with patch_logger('django.request', 'warning') as log_messages:
|
||||
request = self.rf.get('/slash')
|
||||
request.META['HTTP_USER_AGENT'] = 'foo'
|
||||
r = CommonMiddleware().process_request(request)
|
||||
self.assertEqual(r.status_code, 403)
|
||||
self.assertEqual(log_messages, ['Forbidden (User agent): /slash'])
|
||||
with self.assertRaisesMessage(PermissionDenied, 'Forbidden user agent'):
|
||||
CommonMiddleware().process_request(request)
|
||||
|
||||
def test_non_ascii_query_string_does_not_crash(self):
|
||||
"""Regression test for #15152"""
|
||||
|
||||
Reference in New Issue
Block a user