Esempio n. 1
0
    def test_real_certs(self):
        path = os.path.join(os.path.dirname(__file__), 'data',
                            'test_certs.pem')
        with open(path) as f:
            certs = signing.parse_pem_to_certs(f.read())

        assert len(certs) == 3
        # Quick spot check on the CommonName value of the subjects of the certs
        # If these are correct, the entire objects were probably parsed correctly
        assert (certs[0]['tbsCertificate']['subject']['rdnSequence'][4][0]
                ['value'] == b'\x13&normandy.content-signature.mozilla.org')
        assert (certs[1]['tbsCertificate']['subject']['rdnSequence'][3][0]
                ['value'] == b"\x13'Mozilla Signing Services Intermediate 1")
        assert (certs[2]['tbsCertificate']['subject']['rdnSequence'][3][0]
                ['value'] == b'\x13\x16root-ca-production-amo')
Esempio n. 2
0
    def test_real_certs(self):
        path = os.path.join(os.path.dirname(__file__), "data", "test_certs.pem")
        with open(path) as f:
            certs = signing.parse_pem_to_certs(f.read())

        assert len(certs) == 3
        # Quick spot check on the CommonName value of the subjects of the certs
        # If these are correct, the entire objects were probably parsed correctly
        assert (
            certs[0]["tbsCertificate"]["subject"]["rdnSequence"][4][0]["value"]
            == b"\x13&normandy.content-signature.mozilla.org"
        )
        assert (
            certs[1]["tbsCertificate"]["subject"]["rdnSequence"][3][0]["value"]
            == b"\x13'Mozilla Signing Services Intermediate 1"
        )
        assert (
            certs[2]["tbsCertificate"]["subject"]["rdnSequence"][3][0]["value"]
            == b"\x13\x16root-ca-production-amo"
        )
Esempio n. 3
0
 def test_not_a_cert(self):
     bad_data = 'hello world'
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.parse_pem_to_certs(bad_data)
     assert 'Unexpected input "hello world"' in str(exc)
Esempio n. 4
0
 def test_incomplete_cert(self):
     bad_data = '-----BEGIN CERTIFICATE-----\nMIIGXTCCBEWgAwIBAgIEAQAACjANBgkq'
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.parse_pem_to_certs(bad_data)
     assert 'Unexpected end of input.' in str(exc)
Esempio n. 5
0
 def test_empty(self):
     assert signing.parse_pem_to_certs('') == []
Esempio n. 6
0
 def test_not_a_cert(self):
     bad_data = "hello world"
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.parse_pem_to_certs(bad_data)
     assert 'Unexpected input "hello world"' in str(exc)
Esempio n. 7
0
 def test_incomplete_cert(self):
     bad_data = "-----BEGIN CERTIFICATE-----\nMIIGXTCCBEWgAwIBAgIEAQAACjANBgkq"
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.parse_pem_to_certs(bad_data)
     assert "Unexpected end of input." in str(exc)
Esempio n. 8
0
 def test_empty(self):
     assert signing.parse_pem_to_certs("") == []