mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #25017 -- Allowed customizing the DISALLOWED_USER_AGENTS response
This commit is contained in:
parent
a50b66da30
commit
2e70bf3785
3 changed files with 11 additions and 10 deletions
|
@ -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"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue