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


Python x509.PolicyConstraints方法代码示例

本文整理汇总了Python中cryptography.x509.PolicyConstraints方法的典型用法代码示例。如果您正苦于以下问题:Python x509.PolicyConstraints方法的具体用法?Python x509.PolicyConstraints怎么用?Python x509.PolicyConstraints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cryptography.x509的用法示例。


在下文中一共展示了x509.PolicyConstraints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_properties

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PolicyConstraints [as 别名]
def test_properties(self):
        p = PolicyConstraints()
        self.assertIsNone(p.inhibit_policy_mapping)
        self.assertIsNone(p.require_explicit_policy)

        p = PolicyConstraints({'value': {'inhibit_policy_mapping': 1, 'require_explicit_policy': 2}})
        self.assertEqual(p.inhibit_policy_mapping, 1)
        self.assertEqual(p.require_explicit_policy, 2)

        p.inhibit_policy_mapping = 3
        p.require_explicit_policy = 4
        self.assertEqual(p.inhibit_policy_mapping, 3)
        self.assertEqual(p.require_explicit_policy, 4)

        p.inhibit_policy_mapping = None
        p.require_explicit_policy = None
        self.assertIsNone(p.inhibit_policy_mapping)
        self.assertIsNone(p.require_explicit_policy) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:20,代码来源:tests_extensions.py

示例2: test_property_errors

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PolicyConstraints [as 别名]
def test_property_errors(self):
        p = PolicyConstraints({'value': {'inhibit_policy_mapping': 1, 'require_explicit_policy': 2}})
        self.assertEqual(p.inhibit_policy_mapping, 1)
        self.assertEqual(p.require_explicit_policy, 2)

        with self.assertRaisesRegex(ValueError, r'^abc: inhibit_policy_mapping must be int or None$'):
            p.inhibit_policy_mapping = 'abc'
        with self.assertRaisesRegex(ValueError, r'^def: require_explicit_policy must be int or None$'):
            p.require_explicit_policy = 'def'
        self.assertEqual(p.inhibit_policy_mapping, 1)
        self.assertEqual(p.require_explicit_policy, 2)

        with self.assertRaisesRegex(ValueError, r'^-1: inhibit_policy_mapping must be a positive int$'):
            p.inhibit_policy_mapping = -1
        with self.assertRaisesRegex(ValueError, r'^-1: require_explicit_policy must be a positive int$'):
            p.require_explicit_policy = -1
        self.assertEqual(p.inhibit_policy_mapping, 1)
        self.assertEqual(p.require_explicit_policy, 2) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:20,代码来源:tests_extensions.py

示例3: _decode_policy_constraints

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PolicyConstraints [as 别名]
def _decode_policy_constraints(backend, pc):
    pc = backend._ffi.cast("POLICY_CONSTRAINTS *", pc)
    pc = backend._ffi.gc(pc, backend._lib.POLICY_CONSTRAINTS_free)

    require_explicit_policy = _asn1_integer_to_int_or_none(
        backend, pc.requireExplicitPolicy
    )
    inhibit_policy_mapping = _asn1_integer_to_int_or_none(
        backend, pc.inhibitPolicyMapping
    )

    return x509.PolicyConstraints(
        require_explicit_policy, inhibit_policy_mapping
    ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:decode_asn1.py

示例4: extension_type

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PolicyConstraints [as 别名]
def extension_type(self):
        return x509.PolicyConstraints(require_explicit_policy=self.value['require_explicit_policy'],
                                      inhibit_policy_mapping=self.value['inhibit_policy_mapping']) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:5,代码来源:extensions.py

示例5: test_init_error

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PolicyConstraints [as 别名]
def test_init_error(self):
        with self.assertRaisesRegex(ValueError, r'^abc: inhibit_policy_mapping must be int or None$'):
            PolicyConstraints({'value': {'inhibit_policy_mapping': 'abc'}})
        with self.assertRaisesRegex(ValueError, r'^-1: inhibit_policy_mapping must be a positive int$'):
            PolicyConstraints({'value': {'inhibit_policy_mapping': -1}})
        with self.assertRaisesRegex(ValueError, r'^abc: require_explicit_policy must be int or None$'):
            PolicyConstraints({'value': {'require_explicit_policy': 'abc'}})
        with self.assertRaisesRegex(ValueError, r'^-1: require_explicit_policy must be a positive int$'):
            PolicyConstraints({'value': {'require_explicit_policy': -1}}) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:11,代码来源:tests_extensions.py


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