def test_utilities():
    lz4_compressor.register(default=True)
    test_string = "This is a test " * 1000

    compressed_default = compress(test_string)
    compressed_lz4 = lz4_compressor.compress(test_string)

    assert compressed_default == compressed_lz4
    assert compressed_default != test_string

    assert decompress(compressed_default) == test_string
    assert decompress(compressed_lz4) == test_string
예제 #2
0
def test_utilities():
    zlib_compressor.register(default=True)
    test_string = b"This is a test " * 1000

    compressed_default = compress(test_string)
    compressed_zlib = zlib_compressor.compress(test_string)

    assert compressed_default == compressed_zlib
    assert compressed_default != test_string
    assert compressed_zlib != test_string

    assert decompress(compressed_default) == test_string
    assert decompress(compressed_zlib) == test_string
예제 #3
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data), no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data), no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = None
예제 #4
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data),
                                               no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data),
                                                     no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = None
예제 #5
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data),
                                               no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data),
                                                     no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = base.get_root_id()

        # configure default encrytion based on root encryption:
        data = base.loadBefore(self._root_oid, maxtid)[0]
        sig = get_encryption_signature(data)
        if sig:
            _gsm.registerUtility(
                _gsm.getUtility(
                    zerodb.transform.interfaces.IEncrypter,
                    sig.decode(),
                ))
예제 #6
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data), no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data), no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = base.get_root_id()

        # configure default encrytion based on root encryption:
        data = base.loadBefore(self._root_oid, maxtid)[0]
        sig = get_encryption_signature(data)
        if sig:
            _gsm.registerUtility(
                _gsm.getUtility(
                    zerodb.transform.interfaces.IEncrypter,
                    sig.decode(),
                    )
                )