mirror of
https://github.com/django/django.git
synced 2025-01-08 01:15:47 +00:00
Fixed #35414 -- Used default headers in AsyncRequestFactory.
This commit is contained in:
parent
12f4f95405
commit
083e623953
@ -752,6 +752,8 @@ class AsyncRequestFactory(RequestFactory):
|
||||
"scheme": "https" if secure else "http",
|
||||
"headers": [(b"host", b"testserver")],
|
||||
}
|
||||
if self.defaults:
|
||||
extra = {**self.defaults, **extra}
|
||||
if data:
|
||||
s["headers"].extend(
|
||||
[
|
||||
|
@ -1327,6 +1327,19 @@ class AsyncRequestFactoryTest(SimpleTestCase):
|
||||
self.assertEqual(request.headers["x-another-header"], "some other value")
|
||||
self.assertIn("HTTP_X_ANOTHER_HEADER", request.META)
|
||||
|
||||
def test_async_request_factory_default_headers(self):
|
||||
request_factory_with_headers = AsyncRequestFactory(
|
||||
**{
|
||||
"Authorization": "Bearer faketoken",
|
||||
"X-Another-Header": "some other value",
|
||||
}
|
||||
)
|
||||
request = request_factory_with_headers.get("/somewhere/")
|
||||
self.assertEqual(request.headers["authorization"], "Bearer faketoken")
|
||||
self.assertIn("HTTP_AUTHORIZATION", request.META)
|
||||
self.assertEqual(request.headers["x-another-header"], "some other value")
|
||||
self.assertIn("HTTP_X_ANOTHER_HEADER", request.META)
|
||||
|
||||
def test_request_factory_query_string(self):
|
||||
request = self.request_factory.get("/somewhere/", {"example": "data"})
|
||||
self.assertNotIn("Query-String", request.headers)
|
||||
|
Loading…
Reference in New Issue
Block a user