Пример #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_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')
Пример #4
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)
Пример #5
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)
Пример #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)
Пример #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'))
Пример #8
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'))
Пример #9
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'))