File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
import base64
2
2
3
3
import pytest
4
+ import django
4
5
from django .conf import settings
5
6
from django .contrib .auth .models import User
6
7
from django .http import HttpResponse
@@ -218,13 +219,21 @@ def test_post_form_session_auth_passing_csrf(self):
218
219
Ensure POSTing form over session authentication with CSRF token succeeds.
219
220
Regression test for #6088
220
221
"""
221
- from django .middleware .csrf import (
222
- _get_new_csrf_string , _mask_cipher_secret
223
- )
222
+ # Remove this shim when dropping support for Django 2.2.
223
+ if django .VERSION < (3 , 0 ):
224
+ from django .middleware .csrf import _get_new_csrf_token
225
+ else :
226
+ from django .middleware .csrf import (
227
+ _get_new_csrf_string , _mask_cipher_secret
228
+ )
229
+
230
+ def _get_new_csrf_token ():
231
+ return _mask_cipher_secret (_get_new_csrf_string ())
232
+
224
233
self .csrf_client .login (username = self .username , password = self .password )
225
234
226
235
# Set the csrf_token cookie so that CsrfViewMiddleware._get_token() works
227
- token = _mask_cipher_secret ( _get_new_csrf_string () )
236
+ token = _get_new_csrf_token ( )
228
237
self .csrf_client .cookies [settings .CSRF_COOKIE_NAME ] = token
229
238
230
239
# Post the token matching the cookie value
You can’t perform that action at this time.
0 commit comments