def test_parse_certificate_types_too_short(self): """ :py:func:`tls.message.CertificateRequest` fails to parse a certificate request packet whose ``certificate_types`` is too short. """ with pytest.raises(ValidationError) as exc_info: CertificateRequest.from_bytes(self.certificate_types_too_short) assert exc_info.value.args == ('invalid object', 0)
def test_parse_supported_signature_algorithms_too_short(self): """ :py:func:`CertificateRequest` fails to parse a certificate request packet whose ``supported_signature_algorithms`` is too short. """ with pytest.raises(ValidationError) as exc_info: CertificateRequest.from_bytes( self.supported_signature_algorithms_too_short) assert exc_info.value.args == ('invalid object', 0)
def test_parse_certificate_request(self): record = CertificateRequest.from_bytes(self.no_authorities_packet) assert record.certificate_types == [ClientCertificateType.RSA_SIGN] assert len(record.supported_signature_algorithms) == 1 assert record.supported_signature_algorithms[0].hash == \ HashAlgorithm.MD5 assert record.supported_signature_algorithms[0].signature == \ SignatureAlgorithm.RSA assert record.certificate_authorities == b''
def test_as_bytes_certificate_types_too_short(self): """ :py:func:`tls.message.CertificateRequest` fails to construct a certificate request packet whose ``certificate_types`` would be too short. """ record = CertificateRequest.from_bytes(self.no_authorities_packet) record.certificate_types = [] with pytest.raises(ValidationError) as exc_info: record.as_bytes() assert exc_info.value.args == ('invalid object', 0)
def test_as_bytes_supported_signature_algorithms_too_short(self): """ :py:func:`CertificateRequest` fails to construct a certificate request packet whose ``supported_signature_algorithms`` would be too short. """ record = CertificateRequest.from_bytes(self.no_authorities_packet) record.supported_signature_algorithms = [] with pytest.raises(ValidationError) as exc_info: record.as_bytes() assert exc_info.value.args == ('invalid object', 0)
def test_as_bytes_with_authoritites(self): record = CertificateRequest.from_bytes(self.with_authorities_packet) assert record.as_bytes() == self.with_authorities_packet
def test_parse_certificate_request_with_authorities(self): record = CertificateRequest.from_bytes(self.with_authorities_packet) assert record.certificate_authorities == b'03'