Adjusted authentication test for internal CSRF changes.

Private _get_new_csrf_token() was removed in
231de683d8.
This commit is contained in:
Carlton Gibson 2021-09-22 10:06:10 +02:00
parent 4916854492
commit 19b6091554

View File

@ -1,5 +1,6 @@
import base64 import base64
import django
import pytest import pytest
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
@ -218,7 +219,16 @@ class SessionAuthTests(TestCase):
Ensure POSTing form over session authentication with CSRF token succeeds. Ensure POSTing form over session authentication with CSRF token succeeds.
Regression test for #6088 Regression test for #6088
""" """
# Remove this shim when dropping support for Django 2.2.
if django.VERSION < (3, 0):
from django.middleware.csrf import _get_new_csrf_token from django.middleware.csrf import _get_new_csrf_token
else:
from django.middleware.csrf import (
_get_new_csrf_string, _mask_cipher_secret
)
def _get_new_csrf_token():
return _mask_cipher_secret(_get_new_csrf_string())
self.csrf_client.login(username=self.username, password=self.password) self.csrf_client.login(username=self.username, password=self.password)