Beispiel #1
0
def test_compress():
    """Test the compression and decompression functions."""
    compressed_data = cms.compress_message(b'data')
    assert cms.decompress_message(compressed_data) == b'data'

    with pytest.raises(DecompressionError):
        cms.decompress_message(INVALID_DATA)
Beispiel #2
0
    def _decompress_data(payload):
        if payload.get_content_type() == 'application/pkcs7-mime' \
                and payload.get_param('smime-type') == 'compressed-data':
            compressed_data = payload.get_payload(decode=True)
            decompressed_data = decompress_message(compressed_data)
            return True, parse_mime(decompressed_data)

        return False, payload
Beispiel #3
0
    def _decompress_data(self, payload):
        if payload.get_content_type() == 'application/pkcs7-mime' \
                and payload.get_param('smime-type') == 'compressed-data':
            logger.debug(f'Decompressing message {self.message_id} payload :\n'
                         f'{mime_to_bytes(self.payload)}')
            compressed_data = payload.get_payload(decode=True)
            decompressed_data = decompress_message(compressed_data)
            return True, parse_mime(decompressed_data)

        return False, payload
Beispiel #4
0
    def _decompress_data(self, payload):
        if (payload.get_content_type() == "application/pkcs7-mime"
                and payload.get_param("smime-type") == "compressed-data"):
            logger.debug(f"Decompressing message {self.message_id} payload :\n"
                         f"{mime_to_bytes(self.payload)}")
            compressed_data = payload.get_payload(decode=True)
            decompressed_data = decompress_message(compressed_data)
            return True, parse_mime(decompressed_data)

        return False, payload