summaryrefslogtreecommitdiff
path: root/passlib/tests/test_utils.py
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-03-10 18:38:38 -0500
committerEli Collins <elic@assurancetechnologies.com>2012-03-10 18:38:38 -0500
commit2ec09c9b2efc3b5e63467151b12d24196ddf582d (patch)
tree3e12c6f2035d9f7b0fb4b0b59217b11ca1880b55 /passlib/tests/test_utils.py
parent945c3c4f90c0b755a0f607dcceecc9095f165e4f (diff)
downloadpasslib-2ec09c9b2efc3b5e63467151b12d24196ddf582d.tar.gz
safe_crypt() now handles "*0" and similar error returns from crypt()
Diffstat (limited to 'passlib/tests/test_utils.py')
-rw-r--r--passlib/tests/test_utils.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py
index 9d641e1..734479b 100644
--- a/passlib/tests/test_utils.py
+++ b/passlib/tests/test_utils.py
@@ -139,15 +139,19 @@ class MiscTest(TestCase):
self.assertTrue(test_crypt("test", h1))
self.assertFalse(test_crypt("test", h1x))
- # test crypt.crypt() returning None is supported.
- # (Python's Modules/_cryptmodule.c notes some platforms may do this
- # when algorithm is not supported - but don't say which platforms)
+ # check crypt returning variant error indicators
+ # some platforms return None on errors, others empty string,
+ # The BSDs in some cases return ":"
import passlib.utils as mod
orig = mod._crypt
try:
- mod._crypt = lambda secret, hash: None
- self.assertEqual(safe_crypt("test", "aa"), None)
- self.assertFalse(test_crypt("test", h1))
+ fake = None
+ mod._crypt = lambda secret, hash: fake
+ for fake in [None, "", ":", ":0", "*0"]:
+ self.assertEqual(safe_crypt("test", "aa"), None)
+ self.assertFalse(test_crypt("test", h1))
+ fake = 'xxx'
+ self.assertEqual(safe_crypt("test", "aa"), "xxx")
finally:
mod._crypt = orig