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());
}
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();
}
Aggregations