本文整理汇总了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)
示例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)
示例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
)
示例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'])
示例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}})