예제 #1
0
 def test_unicode_password(self):
     user = User()
     with settings():
         bcrypt_set_password(user, u"aáåäeéêëoôö")
     self.assertTrue(bcrypt_check_password(user, u"aáåäeéêëoôö"))
     self.assertFalse(bcrypt_check_password(user, u"aaaaeeeeooo"))
     self.assertFalse(bcrypt_check_password(user, 'invalid'))
예제 #2
0
 def test_change_rounds(self):
     user = User()
     # Hash with 5 rounds
     with settings(BCRYPT_ROUNDS=5):
         bcrypt_set_password(user, 'password')
     password_5 = user.password
     self.assertTrue(bcrypt_check_password(user, 'password'))
     # Hash with 12 rounds
     with settings(BCRYPT_ROUNDS=12):
         bcrypt_set_password(user, 'password')
     password_12 = user.password
     self.assertTrue(bcrypt_check_password(user, 'password'))
예제 #3
0
 def test_change_rounds(self):
     user = User()
     with settings(BCRYPT_ROUNDS=0):
         settings.BCRYPT_ROUNDS = 0
         bcrypt_set_password(user, 'password')
         self.assertBcrypt(user.password, 'password')
예제 #4
0
 def test_set_unusable_password(self):
     user = User()
     with settings():
         bcrypt_set_password(user, None)
     self.assertEqual(user.password, UNUSABLE_PASSWORD)
예제 #5
0
 def test_disabled(self):
     user = User()
     with settings(BCRYPT_ENABLED=False):
         bcrypt_set_password(user, 'password')
     self.assertFalse(user.password.startswith('bc$'), user.password)
예제 #6
0
 def test_set_password(self):
     user = User()
     with settings():
         bcrypt_set_password(user, 'password')
     self.assertBcrypt(user.password, 'password')
예제 #7
0
 def test_unicode_password(self):
     user = User()
     with settings():
         bcrypt_set_password(user, u"aáåäeéêëoôö")
     self.assertTrue(bcrypt_check_password(user, u"aaaaeeeeooo"))
     self.assertFalse(bcrypt_check_password(user, 'invalid'))
예제 #8
0
 def test_bcrypt_password(self):
     user = User()
     with settings():
         bcrypt_set_password(user, 'password')
     self.assertTrue(bcrypt_check_password(user, 'password'))
     self.assertFalse(bcrypt_check_password(user, 'invalid'))