From 26d8e3f302adf0c12f64d614126e57147f8230d6 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Tue, 3 Aug 2021 02:11:50 -0400 Subject: [PATCH] Refs #32800 -- Used the cookie argument to CsrfViewMiddlewareTestMixin._get_request() in more tests. --- tests/csrf_tests/tests.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py index 5da70d77cb..61da1367ac 100644 --- a/tests/csrf_tests/tests.py +++ b/tests/csrf_tests/tests.py @@ -494,8 +494,7 @@ class CsrfViewMiddlewareTestMixin: """ A new token is sent if the csrf_cookie is the empty string. """ - req = self._get_request() - self._set_csrf_cookie(req, '') + req = self._get_request(cookie='') mw = CsrfViewMiddleware(token_view) mw.process_view(req, token_view, (), {}) resp = token_view(req) @@ -1094,8 +1093,7 @@ class CsrfViewMiddlewareTests(CsrfViewMiddlewareTestMixin, SimpleTestCase): If the token is longer than expected, it is ignored and a new token is created. """ - req = self._get_request() - self._set_csrf_cookie(req, 'x' * 100000) + req = self._get_request(cookie='x' * 100000) mw = CsrfViewMiddleware(token_view) mw.process_view(req, token_view, (), {}) resp = mw(req) @@ -1108,8 +1106,7 @@ class CsrfViewMiddlewareTests(CsrfViewMiddlewareTestMixin, SimpleTestCase): new token is created. """ token = ('!@#' + self._csrf_id_token)[:CSRF_TOKEN_LENGTH] - req = self._get_request() - self._set_csrf_cookie(req, token) + req = self._get_request(cookie=token) mw = CsrfViewMiddleware(token_view) mw.process_view(req, token_view, (), {}) resp = mw(req)