Python OpenSSL.crypto 模块,load_pkcs7_data() 实例源码

我们从Python开源项目中,提取了以下45个代码示例,用于说明如何使用OpenSSL.crypto.load_pkcs7_data()

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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))
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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)
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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)
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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")
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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")
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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()
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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()
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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()
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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'
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
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
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
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))
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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))
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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))
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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")
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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)
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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())
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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())
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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)
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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())
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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())
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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)
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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'))
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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")
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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")
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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'))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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")
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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())
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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'))
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
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")