Ejemplo n.º 1
0
 def test_no_migrate_password(self):
     user = User()
     with settings(BCRYPT_MIGRATE=False, BCRYPT_ENABLED_UNDER_TEST=True):
         _set_password(user, 'password')
         self.assertSha1(user.password, 'password')
         self.assertTrue(bcrypt_check_password(user, 'password'))
         self.assertSha1(user.password, 'password')
Ejemplo n.º 2
0
 def test_migrate_sha1_to_bcrypt(self):
     user = User(username="******")
     with settings(BCRYPT_MIGRATE=True, BCRYPT_ENABLED_UNDER_TEST=True):
         _set_password(user, "password")
         self.assertSha1(user.password, "password")
         self.assertTrue(bcrypt_check_password(user, "password"))
         self.assertBcrypt(user.password, "password")
     self.assertEqual(User.objects.get(username="******").password, user.password)
Ejemplo n.º 3
0
 def test_migrate_sha1_to_bcrypt(self):
     user = User(username='******')
     with settings(BCRYPT_MIGRATE=True, BCRYPT_ENABLED_UNDER_TEST=True):
         _set_password(user, 'password')
         self.assertSha1(user.password, 'password')
         self.assertTrue(bcrypt_check_password(user, 'password'))
         self.assertBcrypt(user.password, 'password')
     self.assertEqual(User.objects.get(username='******').password,
                      user.password)
Ejemplo n.º 4
0
def bcrypt_set_password(self, raw_password):
    """
    Sets the user's password to *raw_password*, hashed with bcrypt.
    """
    if not is_enabled() or raw_password is None:
        _set_password(self, raw_password)
    else:
        salt = bcrypt.gensalt(get_rounds())
        self.password = '******' + bcrypt.hashpw(smart_str(raw_password), salt)
Ejemplo n.º 5
0
def bcrypt_set_password(self, raw_password):
    """
    Sets the user's password to *raw_password*, hashed with bcrypt.
    """
    if not is_enabled() or raw_password is None:
        _set_password(self, raw_password)
    else:
        salt = bcrypt.gensalt(get_rounds())
        self.password = '******' + bcrypt.hashpw(smart_str(raw_password), salt)
Ejemplo n.º 6
0
 def test_migate_unicode(self):
     user = User(username='******')
     pw = u'aáåäeéêëoôö'
     with settings(BCRYPT_MIGRATE=True, BCRYPT_ENABLED_UNDER_TEST=True):
         _set_password(user, pw)
         self.assertSha1(user.password, pw)
         self.assertTrue(bcrypt_check_password(user, pw))
         self.assertBcrypt(user.password, pw)
     self.assertEqual(User.objects.get(username='******').password,
                      user.password)
Ejemplo n.º 7
0
 def test_sha1_password(self):
     user = User()
     _set_password(user, 'password')
     self.assertTrue(bcrypt_check_password(user, 'password'))
     self.assertFalse(bcrypt_check_password(user, 'invalid'))