Skip to content

Commit 19b6091

Browse files
committed
Adjusted authentication test for internal CSRF changes.
Private _get_new_csrf_token() was removed in django/django@231de68.
1 parent 4916854 commit 19b6091

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/authentication/test_authentication.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import base64
22

3+
import django
34
import pytest
45
from django.conf import settings
56
from django.contrib.auth.models import User
@@ -218,7 +219,16 @@ def test_post_form_session_auth_passing_csrf(self):
218219
Ensure POSTing form over session authentication with CSRF token succeeds.
219220
Regression test for #6088
220221
"""
221-
from django.middleware.csrf import _get_new_csrf_token
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())
222232

223233
self.csrf_client.login(username=self.username, password=self.password)
224234

0 commit comments

Comments
 (0)