Search in sources :

Example 1 with B2TouchFeature

use of ch.cyberduck.core.b2.B2TouchFeature in project cyberduck by iterate-ch.

the class DefaultAttributesFinderFeatureTest method testFind.

@Test
public void testFind() throws Exception {
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path file = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    new B2TouchFeature(session, fileid).touch(file, new TransferStatus());
    // Find without version id set in attributes
    assertNotNull(new DefaultAttributesFinderFeature(session).find(file).getVersionId());
    new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) B2TouchFeature(ch.cyberduck.core.b2.B2TouchFeature) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with B2TouchFeature

use of ch.cyberduck.core.b2.B2TouchFeature in project cyberduck by iterate-ch.

the class DefaultDownloadFeatureTest method testOverwrite.

@Test
public void testOverwrite() throws Exception {
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    final Path test = new B2TouchFeature(session, fileid).touch(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final byte[] content = new byte[39864];
    new Random().nextBytes(content);
    {
        final TransferStatus status = new TransferStatus().withLength(content.length);
        final HttpResponseOutputStream<BaseB2Response> out = new B2WriteFeature(session, fileid).write(test, status, new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(status, status).withLimit(new Long(content.length)).transfer(new ByteArrayInputStream(content), out);
        out.close();
        test.attributes().setVersionId(((B2FileResponse) out.getStatus()).getFileId());
    }
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final TransferStatus status = new TransferStatus().withLength(content.length);
    new DefaultDownloadFeature(new B2ReadFeature(session, fileid)).download(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback());
    final byte[] buffer = new byte[content.length];
    final InputStream in = local.getInputStream();
    IOUtils.readFully(in, buffer);
    in.close();
    assertArrayEquals(content, buffer);
    new B2DeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) B2ReadFeature(ch.cyberduck.core.b2.B2ReadFeature) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) B2WriteFeature(ch.cyberduck.core.b2.B2WriteFeature) Local(ch.cyberduck.core.Local) B2TouchFeature(ch.cyberduck.core.b2.B2TouchFeature) Random(java.util.Random) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) B2FileResponse(synapticloop.b2.response.B2FileResponse) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with B2TouchFeature

use of ch.cyberduck.core.b2.B2TouchFeature in project cyberduck by iterate-ch.

the class B2TouchFeatureTest method testTouchEncrypted.

@Test
public void testTouchEncrypted() throws Exception {
    final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final CryptoVault cryptomator = new CryptoVault(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)));
    final Path vault = cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    final Path test = new CryptoTouchFeature<>(session, new B2TouchFeature(session, fileid), new B2WriteFeature(session, fileid), cryptomator).touch(new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus());
    assertNotNull(test.attributes().getVersionId());
    assertTrue(new CryptoFindFeature(session, new B2FindFeature(session, fileid), cryptomator).find(test));
    assertEquals(test.attributes(), new CryptoAttributesFeature(session, new B2AttributesFinderFeature(session, fileid), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new B2DeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) B2WriteFeature(ch.cyberduck.core.b2.B2WriteFeature) B2AttributesFinderFeature(ch.cyberduck.core.b2.B2AttributesFinderFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) B2TouchFeature(ch.cyberduck.core.b2.B2TouchFeature) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) B2FindFeature(ch.cyberduck.core.b2.B2FindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with B2TouchFeature

use of ch.cyberduck.core.b2.B2TouchFeature in project cyberduck by iterate-ch.

the class B2TouchFeatureTest method testTouchLongFilenameEncrypted.

@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
    final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService(130).random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    new CryptoTouchFeature<>(session, new B2TouchFeature(session, fileid), new B2WriteFeature(session, fileid), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new B2FindFeature(session, fileid), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new B2DeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) B2WriteFeature(ch.cyberduck.core.b2.B2WriteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) B2TouchFeature(ch.cyberduck.core.b2.B2TouchFeature) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) B2FindFeature(ch.cyberduck.core.b2.B2FindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)4 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)4 Path (ch.cyberduck.core.Path)4 AbstractB2Test (ch.cyberduck.core.b2.AbstractB2Test)4 B2DeleteFeature (ch.cyberduck.core.b2.B2DeleteFeature)4 B2TouchFeature (ch.cyberduck.core.b2.B2TouchFeature)4 B2VersionIdProvider (ch.cyberduck.core.b2.B2VersionIdProvider)4 Delete (ch.cyberduck.core.features.Delete)4 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)4 IntegrationTest (ch.cyberduck.test.IntegrationTest)4 Test (org.junit.Test)4 B2WriteFeature (ch.cyberduck.core.b2.B2WriteFeature)3 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)2 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)2 B2FindFeature (ch.cyberduck.core.b2.B2FindFeature)2 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)2 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)2 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)2 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)1 Local (ch.cyberduck.core.Local)1