summaryrefslogtreecommitdiff
path: root/passlib/tests/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/tests/utils.py')
-rw-r--r--passlib/tests/utils.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index f4dc811..b840aff 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -1152,10 +1152,12 @@ class HandlerCase(TestCase):
c3 = self.do_genconfig(salt=s1[:-1])
self.assertNotEqual(c3, c1)
- # XXX: make this a class-level flag
+ # whether salt should be passed through bcrypt repair function
+ fuzz_salts_need_bcrypt_repair = False
+
def prepare_salt(self, salt):
"prepare generated salt"
- if self.handler.name in ["bcrypt", "django_bcrypt", "django_bcrypt_sha256"]:
+ if self.fuzz_salts_need_bcrypt_repair:
from passlib.utils import bcrypt64
salt = bcrypt64.repair_unused(salt)
return salt
@@ -1958,13 +1960,17 @@ class OsCryptMixin(HandlerCase):
self._patch_safe_crypt()
super(OsCryptMixin, self).setUp()
+ # alternate handler to use for fake os_crypt,
+ # e.g. bcrypt_sha256 uses bcrypt
+ fallback_os_crypt_handler = None
+
def _patch_safe_crypt(self):
"""if crypt() doesn't support current hash alg, this patches
safe_crypt() so that it transparently uses another one of the handler's
backends, so that we can go ahead and test as much of code path
as possible.
"""
- handler = self.handler
+ handler = self.fallback_os_crypt_handler or self.handler
# resolve wrappers, since we want to return crypt compatible hash.
while hasattr(handler, "wrapped"):
handler = handler.wrapped