Exemple #1
0
    def test_upload_and_download_full_size_keys(self):
        self.nodemaker.key_generator = client.KeyGenerator()
        d = self.nodemaker.create_mutable_file()

        def _created(n):
            d = defer.succeed(None)
            d.addCallback(lambda res: n.get_servermap(MODE_READ))
            d.addCallback(lambda smap: smap.dump(StringIO()))
            d.addCallback(
                lambda sio: self.assertTrue("3-of-10" in sio.getvalue()))
            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 1")))
            d.addCallback(lambda res: self.assertThat(res, Is(None)))
            d.addCallback(lambda res: n.download_best_version())
            d.addCallback(
                lambda res: self.assertThat(res, Equals(b"contents 1")))
            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 2")))
            d.addCallback(lambda res: n.download_best_version())
            d.addCallback(
                lambda res: self.assertThat(res, Equals(b"contents 2")))
            d.addCallback(lambda res: n.get_servermap(MODE_WRITE))
            d.addCallback(
                lambda smap: n.upload(MutableData(b"contents 3"), smap))
            d.addCallback(lambda res: n.download_best_version())
            d.addCallback(
                lambda res: self.assertThat(res, Equals(b"contents 3")))
            d.addCallback(lambda res: n.get_servermap(MODE_ANYTHING))
            d.addCallback(lambda smap: n.download_version(
                smap, smap.best_recoverable_version()))
            d.addCallback(
                lambda res: self.assertThat(res, Equals(b"contents 3")))
            return d

        d.addCallback(_created)
        return d
Exemple #2
0
def make_nodemaker(s=None, num_peers=10, keysize=TEST_RSA_KEY_SIZE):
    storage_broker = make_storagebroker(s, num_peers)
    sh = client.SecretHolder("lease secret", "convergence secret")
    keygen = client.KeyGenerator()
    if keysize:
        keygen.set_default_keysize(keysize)
    nodemaker = NodeMaker(storage_broker, sh, None, None, None, {
        "k": 3,
        "n": 10
    }, SDMF_VERSION, keygen)
    return nodemaker
Exemple #3
0
def make_nodemaker_with_storage_broker(storage_broker):
    """
    Make a ``NodeMaker`` using the given storage broker.

    :param StorageFarmBroker peers: The storage broker to use.
    """
    sh = client.SecretHolder(b"lease secret", b"convergence secret")
    keygen = client.KeyGenerator()
    nodemaker = NodeMaker(storage_broker, sh, None,
                          None, None,
                          {"k": 3, "n": 10}, SDMF_VERSION, keygen)
    return nodemaker