summaryrefslogtreecommitdiff
path: root/tests/test_client
diff options
context:
space:
mode:
authorAhmad A. Hussein <ahmadahussein0@gmail.com>2020-05-27 08:10:08 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-27 10:36:52 +0200
commit7c947f0f5a0539add9adf8c4e14726ea509e13ef (patch)
tree90974bb4b3de86fa3d46769a87e55b7bc068ed98 /tests/test_client
parent6425fd3124e50219ba0b6f545d1bf7edfb053a59 (diff)
Fixed #31494 -- Preserved query strings when following HTTP 307/308 redirects in test client.
Diffstat (limited to 'tests/test_client')
-rw-r--r--tests/test_client/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 0b63a3fed5..03bb658952 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -284,6 +284,20 @@ class ClientTest(TestCase):
self.assertEqual(response.request['PATH_INFO'], '/post_view/')
self.assertEqual(response.request['REQUEST_METHOD'], method.upper())
+ def test_follow_307_and_308_preserves_query_string(self):
+ methods = ('post', 'options', 'put', 'patch', 'delete', 'trace')
+ codes = (307, 308)
+ for method, code in itertools.product(methods, codes):
+ with self.subTest(method=method, code=code):
+ req_method = getattr(self.client, method)
+ response = req_method(
+ '/redirect_view_%s_query_string/' % code,
+ data={'value': 'test'},
+ follow=True,
+ )
+ self.assertRedirects(response, '/post_view/?hello=world', status_code=code)
+ self.assertEqual(response.request['QUERY_STRING'], 'hello=world')
+
def test_follow_307_and_308_get_head_query_string(self):
methods = ('get', 'head')
codes = (307, 308)