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