本文整理匯總了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}})