本文整理汇总了Python中passlib.context.CryptPolicy.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python CryptPolicy.to_dict方法的具体用法?Python CryptPolicy.to_dict怎么用?Python CryptPolicy.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类passlib.context.CryptPolicy
的用法示例。
在下文中一共展示了CryptPolicy.to_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_00_constructor
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import to_dict [as 别名]
def test_00_constructor(self):
"test CryptPolicy() constructor"
policy = CryptPolicy(**self.sample_config_1pd)
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
#check with bad key
self.assertRaises(KeyError, CryptPolicy,
schemes = [ "des_crypt", "md5_crypt", "bsdi_crypt", "sha512_crypt"],
bad__key__bsdi_crypt__max_rounds = 30000,
)
#check with bad handler
self.assertRaises(TypeError, CryptPolicy, schemes=[uh.StaticHandler])
#check with multiple handlers
class dummy_1(uh.StaticHandler):
name = 'dummy_1'
self.assertRaises(KeyError, CryptPolicy, schemes=[dummy_1, dummy_1])
#with unknown deprecated value
self.assertRaises(KeyError, CryptPolicy,
schemes=['des_crypt'],
deprecated=['md5_crypt'])
#with unknown default value
self.assertRaises(KeyError, CryptPolicy,
schemes=['des_crypt'],
default='md5_crypt')
示例2: test_00_constructor
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import to_dict [as 别名]
def test_00_constructor(self):
"test CryptPolicy() constructor"
policy = CryptPolicy(**self.sample_config_1pd)
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
policy = CryptPolicy(self.sample_config_1pd)
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
self.assertRaises(TypeError, CryptPolicy, {}, {})
self.assertRaises(TypeError, CryptPolicy, {}, dummy=1)
#check key with too many separators is rejected
self.assertRaises(TypeError, CryptPolicy,
schemes = [ "des_crypt", "md5_crypt", "bsdi_crypt", "sha512_crypt"],
bad__key__bsdi_crypt__max_rounds = 30000,
)
#check nameless handler rejected
class nameless(uh.StaticHandler):
name = None
self.assertRaises(ValueError, CryptPolicy, schemes=[nameless])
# check scheme must be name or crypt handler
self.assertRaises(TypeError, CryptPolicy, schemes=[uh.StaticHandler])
#check name conflicts are rejected
class dummy_1(uh.StaticHandler):
name = 'dummy_1'
self.assertRaises(KeyError, CryptPolicy, schemes=[dummy_1, dummy_1])
#with unknown deprecated value
self.assertRaises(KeyError, CryptPolicy,
schemes=['des_crypt'],
deprecated=['md5_crypt'])
#with unknown default value
self.assertRaises(KeyError, CryptPolicy,
schemes=['des_crypt'],
default='md5_crypt')
示例3: test_21_to_dict
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import to_dict [as 别名]
def test_21_to_dict(self):
"test to_dict() method"
p5 = CryptPolicy(**self.sample_config_5pd)
self.assertEqual(p5.to_dict(), self.sample_config_5pd)
self.assertEqual(p5.to_dict(resolve=True), self.sample_config_5prd)