當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。