我们从Python开源项目中,提取了以下45个代码示例,用于说明如何使用OpenSSL.crypto.load_pkcs7_data()。
def test_load_pkcs7_data(self): """ L{load_pkcs7_data} accepts a PKCS#7 string and returns an instance of L{PKCS7Type}. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertTrue(isinstance(pkcs7, PKCS7Type))
def test_load_pkcs7_data_pem(self): """ `load_pkcs7_data` accepts a PKCS#7 string and returns an instance of `PKCS`. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) assert isinstance(pkcs7, PKCS7)
def test_load_pkcs7_data_asn1(self): """ `load_pkcs7_data` accepts a bytes containing ASN1 data representing PKCS#7 and returns an instance of `PKCS7`. """ pkcs7 = load_pkcs7_data(FILETYPE_ASN1, pkcs7DataASN1) assert isinstance(pkcs7, PKCS7)
def test_load_pkcs7_data_invalid(self): """ If the data passed to `load_pkcs7_data` is invalid, `Error` is raised. """ with pytest.raises(Error): load_pkcs7_data(FILETYPE_PEM, b"foo")
def test_load_pkcs7_type_invalid(self): """ If the type passed to `load_pkcs7_data`, `ValueError` is raised. """ with pytest.raises(ValueError): load_pkcs7_data(object(), b"foo")
def test_type_is_signed(self): """ `PKCS7.type_is_signed` returns `True` if the PKCS7 object is of the type *signed*. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) assert pkcs7.type_is_signed()
def test_type_is_signed_and_enveloped(self): """ `PKCS7.type_is_signedAndEnveloped` returns `False` if the PKCS7 object is not of the type *signed and enveloped*. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) assert not pkcs7.type_is_signedAndEnveloped()
def test_type_is_data(self): """ `PKCS7.type_is_data` returns `False` if the PKCS7 object is not of the type data. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) assert not pkcs7.type_is_data()
def test_get_type_name(self): """ `PKCS7.get_type_name` returns a `str` giving the type name. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) assert pkcs7.get_type_name() == b'pkcs7-signedData'
def test_attribute(self): """ If an attribute other than one of the methods tested here is accessed on an instance of `PKCS7`, `AttributeError` is raised. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) with pytest.raises(AttributeError): pkcs7.foo
def test_load_pkcs7_data_pem(self): """ :py:obj:`load_pkcs7_data` accepts a PKCS#7 string and returns an instance of :py:obj:`PKCS7Type`. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertTrue(isinstance(pkcs7, PKCS7Type))
def test_load_pkcs7_data_asn1(self): """ :py:obj:`load_pkcs7_data` accepts a bytes containing ASN1 data representing PKCS#7 and returns an instance of :py:obj`PKCS7Type`. """ pkcs7 = load_pkcs7_data(FILETYPE_ASN1, pkcs7DataASN1) self.assertTrue(isinstance(pkcs7, PKCS7Type))
def test_load_pkcs7_data_invalid(self): """ If the data passed to :py:obj:`load_pkcs7_data` is invalid, :py:obj:`Error` is raised. """ self.assertRaises(Error, load_pkcs7_data, FILETYPE_PEM, b"foo")
def test_type_is_signed_wrong_args(self): """ :py:obj:`PKCS7Type.type_is_signed` raises :py:obj:`TypeError` if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_signed, None)
def test_type_is_signed(self): """ :py:obj:`PKCS7Type.type_is_signed` returns :py:obj:`True` if the PKCS7 object is of the type *signed*. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertTrue(pkcs7.type_is_signed())
def test_type_is_enveloped(self): """ :py:obj:`PKCS7Type.type_is_enveloped` returns :py:obj:`False` if the PKCS7 object is not of the type *enveloped*. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_enveloped())
def test_type_is_signedAndEnveloped_wrong_args(self): """ :py:obj:`PKCS7Type.type_is_signedAndEnveloped` raises :py:obj:`TypeError` if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_signedAndEnveloped, None)
def test_type_is_signedAndEnveloped(self): """ :py:obj:`PKCS7Type.type_is_signedAndEnveloped` returns :py:obj:`False` if the PKCS7 object is not of the type *signed and enveloped*. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_signedAndEnveloped())
def test_type_is_data(self): """ :py:obj:`PKCS7Type.type_is_data` returns :py:obj:`False` if the PKCS7 object is not of the type data. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_data())
def test_type_is_data_wrong_args(self): """ :py:obj:`PKCS7Type.type_is_data` raises :py:obj:`TypeError` if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_data, None)
def test_get_type_name(self): """ :py:obj:`PKCS7Type.get_type_name` returns a :py:obj:`str` giving the type name. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertEquals(pkcs7.get_type_name(), b('pkcs7-signedData'))
def test_attribute(self): """ If an attribute other than one of the methods tested here is accessed on an instance of :py:obj:`PKCS7Type`, :py:obj:`AttributeError` is raised. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(AttributeError, getattr, pkcs7, "foo")
def test_type_is_signed_wrong_args(self): """ L{PKCS7Type.type_is_signed} raises L{TypeError} if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_signed, None)
def test_type_is_signed(self): """ L{PKCS7Type.type_is_signed} returns C{True} if the PKCS7 object is of the type I{signed}. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertTrue(pkcs7.type_is_signed())
def test_type_is_enveloped(self): """ L{PKCS7Type.type_is_enveloped} returns C{False} if the PKCS7 object is not of the type I{enveloped}. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_enveloped())
def test_type_is_signedAndEnveloped_wrong_args(self): """ L{PKCS7Type.type_is_signedAndEnveloped} raises L{TypeError} if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_signedAndEnveloped, None)
def test_type_is_signedAndEnveloped(self): """ L{PKCS7Type.type_is_signedAndEnveloped} returns C{False} if the PKCS7 object is not of the type I{signed and enveloped}. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_signedAndEnveloped())
def test_type_is_data(self): """ L{PKCS7Type.type_is_data} returns C{False} if the PKCS7 object is not of the type data. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertFalse(pkcs7.type_is_data())
def test_type_is_data_wrong_args(self): """ L{PKCS7Type.type_is_data} raises L{TypeError} if called with any arguments. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(TypeError, pkcs7.type_is_data, None)
def test_get_type_name(self): """ L{PKCS7Type.get_type_name} returns a C{str} giving the type name. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertEquals(pkcs7.get_type_name(), b('pkcs7-signedData'))
def test_attribute(self): """ If an attribute other than one of the methods tested here is accessed on an instance of L{PKCS7Type}, L{AttributeError} is raised. """ pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data) self.assertRaises(AttributeError, getattr, pkcs7, "foo")