diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-05-11 09:13:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 09:13:45 +0200 |
commit | 02dbf1667c6da61ea9346f7c9f174a158b896811 (patch) | |
tree | 56b519f7529b6a29cbb90155c363d57585418e03 /tests/auth_tests | |
parent | 262fde94de5eb6544fc0f289575583436613c045 (diff) | |
download | django-02dbf1667c6da61ea9346f7c9f174a158b896811.tar.gz |
Fixed #33691 -- Deprecated django.contrib.auth.hashers.CryptPasswordHasher.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r-- | tests/auth_tests/test_hashers.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py index b767c2823d..2faf2499b0 100644 --- a/tests/auth_tests/test_hashers.py +++ b/tests/auth_tests/test_hashers.py @@ -18,9 +18,11 @@ from django.contrib.auth.hashers import ( is_password_usable, make_password, ) -from django.test import SimpleTestCase +from django.test import SimpleTestCase, ignore_warnings from django.test.utils import override_settings +from django.utils.deprecation import RemovedInDjango50Warning +# RemovedInDjango50Warning. try: import crypt except ImportError: @@ -201,6 +203,7 @@ class TestUtilsHashPass(SimpleTestCase): with self.assertRaisesMessage(ValueError, msg): hasher.encode("password", salt="salt") + @ignore_warnings(category=RemovedInDjango50Warning) @skipUnless(crypt, "no crypt module to generate password.") @override_settings( PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"] @@ -219,6 +222,7 @@ class TestUtilsHashPass(SimpleTestCase): self.assertTrue(check_password("", blank_encoded)) self.assertFalse(check_password(" ", blank_encoded)) + @ignore_warnings(category=RemovedInDjango50Warning) @skipUnless(crypt, "no crypt module to generate password.") @override_settings( PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"] @@ -229,6 +233,7 @@ class TestUtilsHashPass(SimpleTestCase): with self.assertRaisesMessage(ValueError, msg): hasher.encode("password", salt="a") + @ignore_warnings(category=RemovedInDjango50Warning) @skipUnless(crypt, "no crypt module to generate password.") @override_settings( PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"] @@ -240,6 +245,15 @@ class TestUtilsHashPass(SimpleTestCase): with self.assertRaisesMessage(TypeError, msg): hasher.encode("password", salt="ab") + @skipUnless(crypt, "no crypt module to generate password.") + @override_settings( + PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"] + ) + def test_crypt_deprecation_warning(self): + msg = "django.contrib.auth.hashers.CryptPasswordHasher is deprecated." + with self.assertRaisesMessage(RemovedInDjango50Warning, msg): + get_hasher("crypt") + @skipUnless(bcrypt, "bcrypt not installed") def test_bcrypt_sha256(self): encoded = make_password("lètmein", hasher="bcrypt_sha256") |