Skip to content

Commit

Permalink
Use PBKDF2PasswordHasher in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaudino committed Mar 18, 2024
1 parent 361493e commit 36b5664
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions tests/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@
},
]

# sha1 hasher was removed as a default in django 1.10. Need it for the tests.
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
Expand Down
6 changes: 3 additions & 3 deletions tests/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ def test_uses_auth_password_validators(self):


@skipIfCustomUser
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@override_settings(USE_TZ=False)
class UserChangeFormTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.u1 = User.objects.create(
password='sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161',
password='pbkdf2_sha256$600000$U3$rhq9d758wGq/JU5/+bkG8OqDVY05d04zKD4cuamR+Sk=',
last_login=datetime.datetime(2006, 12, 17, 7, 3, 31), is_superuser=False, username='testclient',
first_name='Test', last_name='Client', email='[email protected]', is_staff=False, is_active=True,
date_joined=datetime.datetime(2006, 12, 17, 7, 3, 31)
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_bug_19133(self):
form = UserChangeForm(instance=user, data=post_data)

self.assertTrue(form.is_valid())
self.assertEqual(form.cleaned_data['password'], 'sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161')
self.assertEqual(form.cleaned_data['password'], 'pbkdf2_sha256$600000$U3$rhq9d758wGq/JU5/+bkG8OqDVY05d04zKD4cuamR+Sk=')

def test_bug_19349_bound_password_field(self):
user = User.objects.get(username='testclient')
Expand Down

0 comments on commit 36b5664

Please sign in to comment.