Search in sources :

Example 61 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature 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 62 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class BoxThresholdUploadServiceTest method testUploadVaultWithBulkFeature.

@Test
public void testUploadVaultWithBulkFeature() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final Path container = new BoxDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(AbstractPath.Type.directory)), new TransferStatus().withLength(0L));
    final Path vault = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = RandomUtils.nextBytes(50240000);
    IOUtils.write(content, local.getOutputStream(false));
    final TransferStatus writeStatus = new TransferStatus();
    final FileHeader header = cryptomator.getFileHeaderCryptor().create();
    writeStatus.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
    writeStatus.setLength(content.length);
    final CryptoBulkFeature<Map<TransferItem, TransferStatus>> bulk = new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new BoxDeleteFeature(session, fileid), cryptomator);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), writeStatus), new DisabledConnectionCallback());
    final BytecountStreamListener count = new BytecountStreamListener();
    final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, new BoxThresholdUploadService(session, fileid, registry), new BoxThresholdWriteFeature(session, fileid), cryptomator);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, writeStatus, new DisabledConnectionCallback());
    assertEquals(content.length, count.getSent());
    assertTrue(writeStatus.isComplete());
    assertTrue(new CryptoFindFeature(session, new BoxFindFeature(session, fileid), cryptomator).find(test));
    assertEquals(content.length, new CryptoAttributesFeature(session, new BoxAttributesFinderFeature(session, fileid), cryptomator).find(test).getSize());
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final TransferStatus readStatus = new TransferStatus().withLength(content.length);
    final InputStream in = new CryptoReadFeature(session, new BoxReadFeature(session, fileid), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
    new StreamCopier(readStatus, readStatus).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    cryptomator.getFeature(session, Delete.class, new BoxDeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) BoxThresholdWriteFeature(ch.cyberduck.core.box.BoxThresholdWriteFeature) CryptoBulkFeature(ch.cyberduck.core.cryptomator.features.CryptoBulkFeature) BoxThresholdUploadService(ch.cyberduck.core.box.BoxThresholdUploadService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) FileHeader(org.cryptomator.cryptolib.api.FileHeader) BoxAttributesFinderFeature(ch.cyberduck.core.box.BoxAttributesFinderFeature) CryptoUploadFeature(ch.cyberduck.core.cryptomator.features.CryptoUploadFeature) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) BoxDeleteFeature(ch.cyberduck.core.box.BoxDeleteFeature) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) InputStream(java.io.InputStream) DisabledBulkFeature(ch.cyberduck.core.shared.DisabledBulkFeature) Local(ch.cyberduck.core.Local) BoxReadFeature(ch.cyberduck.core.box.BoxReadFeature) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) BoxFindFeature(ch.cyberduck.core.box.BoxFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) BoxDirectoryFeature(ch.cyberduck.core.box.BoxDirectoryFeature) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Map(java.util.Map) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) BoxFileidProvider(ch.cyberduck.core.box.BoxFileidProvider) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbtractBoxTest(ch.cyberduck.core.box.AbtractBoxTest)

Aggregations

CryptoAttributesFeature (ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature)62 Delete (ch.cyberduck.core.features.Delete)62 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)62 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)62 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)62 IntegrationTest (ch.cyberduck.test.IntegrationTest)62 Test (org.junit.Test)62 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)60 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)60 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)60 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)60 Path (ch.cyberduck.core.Path)60 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)53 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)36 StreamCopier (ch.cyberduck.core.io.StreamCopier)34 CryptoReadFeature (ch.cyberduck.core.cryptomator.features.CryptoReadFeature)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)33 InputStream (java.io.InputStream)33 PathAttributes (ch.cyberduck.core.PathAttributes)24 Local (ch.cyberduck.core.Local)21