Exemplo n.º 1
0
def test_root_encryption(db):
    _gsm = getGlobalSiteManager()
    utility = _gsm.getUtility(IEncrypter)
    edata, _ = db._connection._storage.base.load(db._connection._db._root_oid)
    assert get_encryption_signature(edata) == utility.name
    for obj in db._root.values():
        edata, _ = db._connection._storage.base.load(obj._p_oid)
        assert get_encryption_signature(edata) == ""
Exemplo n.º 2
0
 def _init_root(self, storage, **kw):
     oid, new = storage.get_root_id()
     storage._root_oid = oid
     if new:
         create_root(storage, oid=oid, check_new=False)
     elif hasattr(storage, "base"):
         # If a different encryption was used for this DB,
         # use that as default
         edata, _ = storage.base.load(oid)
         sig = get_encryption_signature(edata)
         utility = _gsm.getUtility(IEncrypter, name=sig.decode())
         if _gsm.getUtility(IEncrypter) is not utility:
             _gsm.registerUtility(utility)
     self._root_oid = oid