예제 #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
파일: tests.py 프로젝트: hph/django-bcrypt
 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'))