From a2440f7d568867916c011a1a7920d7d3e11ab369 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Sat, 25 Jul 2015 22:30:56 -0400 Subject: tests: minor fix so HasRounds.bitsize() test isn't dependant on hardcoded default rounds values. serves me right for tweaking the default rounds *after* a release. --- passlib/tests/test_utils_handlers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/passlib/tests/test_utils_handlers.py b/passlib/tests/test_utils_handlers.py index 8e408ca..0b5522d 100644 --- a/passlib/tests/test_utils_handlers.py +++ b/passlib/tests/test_utils_handlers.py @@ -18,7 +18,7 @@ from passlib.utils import getrandstr, JYTHON, rng from passlib.utils.compat import b, bytes, bascii_to_str, str_to_uascii, \ uascii_to_str, unicode, PY_MAX_25, SUPPORTS_DIR_METHOD import passlib.utils.handlers as uh -from passlib.tests.utils import HandlerCase, TestCase, catch_warnings +from passlib.tests.utils import HandlerCase, TestCase, catch_warnings, patchAttr from passlib.utils.compat import u, PY3 # module log = getLogger(__name__) @@ -44,6 +44,8 @@ def _makelang(alphabet, size): class SkeletonTest(TestCase): """test hash support classes""" + patchAttr = patchAttr + #=================================================================== # StaticHandler #=================================================================== @@ -524,10 +526,14 @@ class SkeletonTest(TestCase): {'checksum': 186, 'salt': 132}) # linear rounds + # NOTE: +3 comes from int(math.log(.1,2)), + # where 0.1 = 10% = default allowed variation in rounds + self.patchAttr(hash.sha256_crypt, "default_rounds", 1 << (14 + 3)) self.assertEqual(hash.sha256_crypt.bitsize(), {'checksum': 258, 'rounds': 14, 'salt': 96}) # raw checksum + self.patchAttr(hash.pbkdf2_sha1, "default_rounds", 1 << (13 + 3)) self.assertEqual(hash.pbkdf2_sha1.bitsize(), {'checksum': 160, 'rounds': 13, 'salt': 128}) -- cgit v1.2.1