Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #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()
Beispiel #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'
Beispiel #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()
Beispiel #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'
Beispiel #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()
Beispiel #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()
Beispiel #11
0
 def test_as_bytes(self):
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Beispiel #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'
Beispiel #13
0
 def test_as_bytes(self):
     record = Certificate.from_bytes(self.packet)
     assert record.as_bytes() == self.packet
Beispiel #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'