summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--passlib/context.py2
-rw-r--r--passlib/tests/test_context.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/passlib/context.py b/passlib/context.py
index 2b091f1..940954d 100644
--- a/passlib/context.py
+++ b/passlib/context.py
@@ -1901,7 +1901,7 @@ class CryptContext(object):
"""helper used to parse ``cat__scheme__option`` keys into a tuple"""
# split string into 1-3 parts
assert isinstance(ckey, str)
- parts = ckey.split("." if "." in ckey else "__")
+ parts = ckey.replace(".","__").split("__")
count = len(parts)
if count == 1:
cat, scheme, key = None, None, parts[0]
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index 85dc7d0..cdd8746 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -423,6 +423,14 @@ sha512_crypt__min_rounds = 45000
self.assertRaises(TypeError, CryptContext,
category__scheme__option__invalid = 30000)
+ # keys with mixed separators should be handled correctly.
+ # (testing actual data, not to_dict(), since re-render hid original bug)
+ self.assertRaises(KeyError, parse,
+ **{"admin.context__schemes":"md5_crypt"})
+ ctx = CryptContext(**{"schemes":"md5_crypt,des_crypt",
+ "admin.context__default":"des_crypt"})
+ self.assertEqual(ctx.default_scheme("admin"), "des_crypt")
+
#
# context option -specific tests
#