Esempio n. 1
0
 def test_parse_certificate_too_long(self):
     """
     :py:meth:`tls.message.Certificate.from_bytes` rejects a packet
     whose ``certificate_list`` is too long.
     """
     with pytest.raises(ValidationError):
         Certificate.from_bytes(self.certificates_too_long)
Esempio n. 2
0
 def test_parse_certificate_too_short(self):
     """
     :py:meth:`tls.message.Certificate.from_bytes` rejects a packet
     whose ``certificate_list`` is too short.
     """
     with pytest.raises(ValidationError):
         Certificate.from_bytes(self.certificates_too_short)
Esempio n. 3
0
 def test_as_bytes(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` returns a valid
     packet.
     """
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Esempio n. 4
0
 def test_as_bytes(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` returns a valid
     packet.
     """
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Esempio n. 5
0
 def test_as_bytes_too_short(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` fails to construct
     a packet whose ``certificate_list`` would be too long.
     """
     certificate = Certificate.from_bytes(self.packet)
     certificate.certificate_list = []
     with pytest.raises(ValidationError):
         certificate.as_bytes()
Esempio n. 6
0
 def test_parse_certificate(self):
     """
     :py:meth:`tls.message.Certificate.from_bytes` parses a valid
     packet.
     """
     record = Certificate.from_bytes(self.packet)
     assert isinstance(record, Certificate)
     assert len(record.certificate_list) == 1
     assert record.certificate_list[0].asn1_cert == b'ABC'
Esempio n. 7
0
 def test_as_bytes_too_short(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` fails to construct
     a packet whose ``certificate_list`` would be too long.
     """
     certificate = Certificate.from_bytes(self.packet)
     certificate.certificate_list = []
     with pytest.raises(ValidationError):
         certificate.as_bytes()
Esempio n. 8
0
 def test_parse_certificate(self):
     """
     :py:meth:`tls.message.Certificate.from_bytes` parses a valid
     packet.
     """
     record = Certificate.from_bytes(self.packet)
     assert isinstance(record, Certificate)
     assert len(record.certificate_list) == 1
     assert record.certificate_list[0].asn1_cert == b'ABC'
Esempio n. 9
0
 def test_as_bytes_too_long(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` fails to construct
     a packet whose ``certificate_list`` would be too short.
     """
     certificate = Certificate.from_bytes(self.packet)
     # this is kind of a cheat: the length of the packet ends up
     # being too large, but not because there are too many
     # ASN1Certs.  there's only one very large ASN1Cert.
     certificate.certificate_list = [ASN1Cert(b'a' * 0x1000000)]
     with pytest.raises(ValidationError):
         certificate.as_bytes()
Esempio n. 10
0
 def test_as_bytes_too_long(self):
     """
     :py:meth:`tls.message.Certificate.as_bytes` fails to construct
     a packet whose ``certificate_list`` would be too short.
     """
     certificate = Certificate.from_bytes(self.packet)
     # this is kind of a cheat: the length of the packet ends up
     # being too large, but not because there are too many
     # ASN1Certs.  there's only one very large ASN1Cert.
     certificate.certificate_list = [ASN1Cert(b'a' * 0x1000000)]
     with pytest.raises(ValidationError):
         certificate.as_bytes()
Esempio n. 11
0
 def test_as_bytes(self):
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Esempio n. 12
0
 def test_parse_certificate(self):
     record = Certificate.from_bytes(self.packet)
     assert isinstance(record, Certificate)
     assert len(record.certificate_list) == 1
     assert record.certificate_list[0].asn1_cert == b'ABC'
Esempio n. 13
0
 def test_as_bytes(self):
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Esempio n. 14
0
 def test_parse_certificate(self):
     record = Certificate.from_bytes(self.packet)
     assert isinstance(record, Certificate)
     assert len(record.certificate_list) == 1
     assert record.certificate_list[0].asn1_cert == b'ABC'