def test_can_generate_usable_passwords_for_users_using_sha512(self): # Setup hasher = DrupalPasswordHasher() user = User.objects.create_user(username='******', email='*****@*****.**', password='******') user.password = hasher.encode('dummypassword', hasher.salt()) user.save() # Run & check assert self.client.login(username='******', password='******')
def test_safe_summary(self): # Setup hasher = DrupalPasswordHasher() password = '******' encoded = hasher.encode(password, hasher.salt()) # Run & check summary_dict = hasher.safe_summary(encoded) assert summary_dict['algorithm'] == 'drupal' assert summary_dict['iterations'] > 0 assert len(summary_dict['salt']) == 8 assert len(summary_dict['hash']) == hasher._DRUPAL_HASH_LENGTH - 12
def test_will_not_be_used_if_the_password_of_the_user_is_updated(self): # Setup hasher = DrupalPasswordHasher() user = User.objects.create_user(username='******', email='*****@*****.**', password='******') user.password = hasher.encode('dummypassword', hasher.salt()) user.save() user.set_password('newdummypassword') user.save() # Run & check assert self.client.login(username='******', password='******') algorithm, _, _, _ = user.password.split('$') assert algorithm == 'pbkdf2_sha256'