use of ch.cyberduck.core.s3.S3WriteFeature in project cyberduck by iterate-ch.
the class S3DirectoryFeatureTest method testMakeDirectoryEncrypted.
@Test
public void testMakeDirectoryEncrypted() throws Exception {
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
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 Path test = cryptomator.getFeature(session, Directory.class, new S3DirectoryFeature(session, new S3WriteFeature(session))).mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final String versionId = test.attributes().getVersionId();
assertTrue(test.getType().contains(Path.Type.placeholder));
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(test));
assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
final PathAttributes attributes = new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), cryptomator).find(test);
assertEquals(versionId, attributes.getVersionId());
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.s3.S3WriteFeature in project cyberduck by iterate-ch.
the class S3DirectoryFeatureTest method testMakeDirectoryLongFilenameEncrypted.
@Test
public void testMakeDirectoryLongFilenameEncrypted() throws Exception {
assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
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 Path test = cryptomator.getFeature(session, Directory.class, new S3DirectoryFeature(session, new S3WriteFeature(session))).mkdir(new Path(vault, new AlphanumericRandomStringService(130).random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final String versionId = test.attributes().getVersionId();
assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
final PathAttributes attributes = new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), cryptomator).find(test);
assertEquals(versionId, attributes.getVersionId());
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.s3.S3WriteFeature in project cyberduck by iterate-ch.
the class S3MoveFeatureTest method testMove.
@Test
public void testMove() throws Exception {
final Path home = new Path("test-eu-central-1-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 folder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
final Path file = new Path(folder, new AlphanumericRandomStringService().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));
cryptomator.getFeature(session, Directory.class, new S3DirectoryFeature(session, new S3WriteFeature(session))).mkdir(folder, new TransferStatus());
new CryptoTouchFeature<StorageObject>(session, new S3TouchFeature(session), new S3WriteFeature(session), cryptomator).touch(file, new TransferStatus());
assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(file));
final Move move = cryptomator.getFeature(session, Move.class, new S3MoveFeature(session));
// rename file
final Path fileRenamed = new Path(folder, "f1", EnumSet.of(Path.Type.file));
move.move(file, fileRenamed, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
assertFalse(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(file));
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(fileRenamed));
// rename folder
final Path folderRenamed = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
move.move(folder, folderRenamed, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
assertFalse(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(folder));
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(folderRenamed));
final Path fileRenamedInRenamedFolder = new Path(folderRenamed, "f1", EnumSet.of(Path.Type.file));
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(fileRenamedInRenamedFolder));
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(fileRenamedInRenamedFolder, folderRenamed, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.s3.S3WriteFeature in project cyberduck by iterate-ch.
the class S3MultipartUploadServiceTest method testUploadSinglePart.
@Test
public void testUploadSinglePart() throws Exception {
// 5L * 1024L * 1024L
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final Path vault = new Path(home, 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);
session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
final CryptoUploadFeature m = new CryptoUploadFeature<>(session, new S3MultipartUploadService(session, new S3WriteFeature(session), 5L * 1024L * 1024L, 5), new S3WriteFeature(session), cryptomator);
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
final int length = 5242880;
final byte[] content = RandomUtils.nextBytes(length);
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 BytecountStreamListener count = new BytecountStreamListener();
m.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, writeStatus, null);
assertEquals(content.length, count.getSent());
assertTrue(writeStatus.isComplete());
assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(test));
assertEquals(content.length, new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), 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 S3ReadFeature(session), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
new StreamCopier(readStatus, readStatus).transfer(in, buffer);
assertArrayEquals(content, buffer.toByteArray());
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
use of ch.cyberduck.core.s3.S3WriteFeature in project cyberduck by iterate-ch.
the class S3TouchFeatureTest method testTouchEncrypted.
@Test
public void testTouchEncrypted() throws Exception {
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
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 Path test = new CryptoTouchFeature<>(session, new S3TouchFeature(session), new S3WriteFeature(session), cryptomator).touch(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
assertEquals(test.attributes(), new CryptoAttributesFeature(session, new S3AttributesFinderFeature(session), cryptomator).find(test));
cryptomator.getFeature(session, Delete.class, new S3DefaultDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Aggregations