예제 #1
0
 def test_91_django_generation(self):
     """test against output of Django's make_password()"""
     from passlib.tests.test_ext_django import DJANGO_VERSION
     # make_password() not added until 1.4
     min_django_version = max(self.min_django_version, (1, 4))
     if DJANGO_VERSION < min_django_version:
         raise self.skipTest("Django >= %s not installed" %
                             vstr(min_django_version))
     from passlib.utils import tick
     from django.contrib.auth.hashers import make_password
     name = self.handler.django_name  # set for all the django_* handlers
     end = tick() + self.max_fuzz_time / 2
     while tick() < end:
         secret, other = self.get_fuzz_password_pair()
         if not secret:  # django 1.4 rejects empty passwords.
             continue
         if DJANGO_VERSION >= (
                 1, 5) and self.django_has_encoding_glitch and isinstance(
                     secret, bytes):
             # e.g. unsalted_md5 on 1.5 and higher try to combine
             # salt + password before encoding to bytes, leading to ascii error.
             # this works around that issue.
             secret = secret.decode("utf-8")
         hash = make_password(secret, hasher=name)
         self.assertTrue(self.do_identify(hash))
         self.assertTrue(self.do_verify(secret, hash))
         self.assertFalse(self.do_verify(other, hash))
예제 #2
0
 def test_91_django_generation(self):
     """test against output of Django's make_password()"""
     self._require_django_support()
     # XXX: esp. when it's no longer supported by django,
     #      should verify it's *NOT* recognized
     from passlib.utils import tick
     from django.contrib.auth.hashers import make_password
     name = self.handler.django_name  # set for all the django_* handlers
     end = tick() + self.max_fuzz_time / 2
     generator = self.FuzzHashGenerator(self, self.getRandom())
     while tick() < end:
         secret, other = generator.random_password_pair()
         if not secret:  # django rejects empty passwords.
             continue
         if isinstance(secret, bytes):
             secret = secret.decode("utf-8")
         hash = make_password(secret, hasher=name)
         self.assertTrue(self.do_identify(hash))
         self.assertTrue(self.do_verify(secret, hash))
         self.assertFalse(self.do_verify(other, hash))
예제 #3
0
 def test_91_django_generation(self):
     """test against output of Django's make_password()"""
     from passlib.tests.test_ext_django import DJANGO_VERSION
     # make_password() not added until 1.4
     min_django_version = max(self.min_django_version, (1,4))
     if DJANGO_VERSION < min_django_version:
         raise self.skipTest("Django >= %s not installed" % vstr(min_django_version))
     from passlib.utils import tick
     from django.contrib.auth.hashers import make_password
     name = self.handler.django_name # set for all the django_* handlers
     end = tick() + self.max_fuzz_time/2
     while tick() < end:
         secret, other = self.get_fuzz_password_pair()
         if not secret: # django 1.4 rejects empty passwords.
             continue
         if DJANGO_VERSION >= (1,5) and self.django_has_encoding_glitch and isinstance(secret, bytes):
             # e.g. unsalted_md5 on 1.5 and higher try to combine
             # salt + password before encoding to bytes, leading to ascii error.
             # this works around that issue.
             secret = secret.decode("utf-8")
         hash = make_password(secret, hasher=name)
         self.assertTrue(self.do_identify(hash))
         self.assertTrue(self.do_verify(secret, hash))
         self.assertFalse(self.do_verify(other, hash))
예제 #4
0
 def helper():
     start = tick()
     hasher.verify(secret, hash)
     return tick() - start
예제 #5
0
 def helper():
     start = tick()
     hasher.verify(secret, hash)
     return tick() - start