mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #16040 -- Preserved scheme, host and port in the test client when following a redirect.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17157 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -368,6 +368,18 @@ class AssertRedirectsTests(TestCase):
|
||||
'/test_client_regress/no_template_view/', 301, 200)
|
||||
self.assertEqual(len(response.redirect_chain), 3)
|
||||
|
||||
def test_redirect_to_different_host(self):
|
||||
"The test client will preserve scheme, host and port changes"
|
||||
response = self.client.get('/test_client_regress/redirect_other_host/', follow=True)
|
||||
self.assertRedirects(response,
|
||||
'https://otherserver:8443/test_client_regress/no_template_view/',
|
||||
status_code=301, target_status_code=200)
|
||||
# We can't use is_secure() or get_host()
|
||||
# because response.request is a dictionary, not an HttpRequest
|
||||
self.assertEqual(response.request.get('wsgi.url_scheme'), 'https')
|
||||
self.assertEqual(response.request.get('SERVER_NAME'), 'otherserver')
|
||||
self.assertEqual(response.request.get('SERVER_PORT'), '8443')
|
||||
|
||||
def test_redirect_chain_on_non_redirect_page(self):
|
||||
"An assertion is raised if the original page couldn't be retrieved as expected"
|
||||
# This page will redirect with code 301, not 302
|
||||
|
||||
Reference in New Issue
Block a user