当前位置: 首页>>代码示例>>Python>>正文


Python CryptPolicy.to_dict方法代码示例

本文整理汇总了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')
开发者ID:GabrielDiniz,项目名称:FluxNetControl,代码行数:30,代码来源:test_context.py

示例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')
开发者ID:bbBradenbb,项目名称:gae-starter-kit,代码行数:41,代码来源:test_context_deprecated.py

示例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)
开发者ID:bbBradenbb,项目名称:gae-starter-kit,代码行数:7,代码来源:test_context_deprecated.py


注:本文中的passlib.context.CryptPolicy.to_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。