Search in sources :

Example 16 with DefaultTouchFeature

use of ch.cyberduck.core.shared.DefaultTouchFeature in project cyberduck by iterate-ch.

the class SFTPMoveFeatureTest method testMoveFile.

@Test
public void testMoveFile() throws Exception {
    final Path home = new SFTPHomeDirectoryService(session).find();
    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 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 SFTPDirectoryFeature(session)).mkdir(folder, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(folder));
    final Path template = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Path file = new CryptoTouchFeature<>(session, new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new SFTPWriteFeature(session)), new SFTPWriteFeature(session), cryptomator), new SFTPWriteFeature(session), cryptomator).touch(template, new TransferStatus()).withAttributes(new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(template));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(file));
    final Move move = cryptomator.getFeature(session, Move.class, new SFTPMoveFeature(session));
    // rename file
    final Path fileRenamed = move.move(file, new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertEquals(fileRenamed.attributes(), new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(fileRenamed));
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(file));
    assertEquals(fileRenamed.attributes(), new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(fileRenamed));
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(fileRenamed));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).delete(Arrays.asList(fileRenamed, folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : SFTPAttributesFinderFeature(ch.cyberduck.core.sftp.SFTPAttributesFinderFeature) Delete(ch.cyberduck.core.features.Delete) SFTPFindFeature(ch.cyberduck.core.sftp.SFTPFindFeature) SFTPWriteFeature(ch.cyberduck.core.sftp.SFTPWriteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) Move(ch.cyberduck.core.features.Move) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoTouchFeature(ch.cyberduck.core.cryptomator.features.CryptoTouchFeature) SFTPDirectoryFeature(ch.cyberduck.core.sftp.SFTPDirectoryFeature) Directory(ch.cyberduck.core.features.Directory) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) SFTPDeleteFeature(ch.cyberduck.core.sftp.SFTPDeleteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) SFTPHomeDirectoryService(ch.cyberduck.core.sftp.SFTPHomeDirectoryService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) SFTPMoveFeature(ch.cyberduck.core.sftp.SFTPMoveFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractSFTPTest(ch.cyberduck.core.sftp.AbstractSFTPTest)

Example 17 with DefaultTouchFeature

use of ch.cyberduck.core.shared.DefaultTouchFeature in project cyberduck by iterate-ch.

the class DefaultTouchFeatureTest method testTouchEncrypted.

@Test
public void testTouchEncrypted() throws Exception {
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, UUID.randomUUID().toString(), 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));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new SFTPWriteFeature(session)), new SFTPWriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).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) SFTPWriteFeature(ch.cyberduck.core.sftp.SFTPWriteFeature) SFTPDeleteFeature(ch.cyberduck.core.sftp.SFTPDeleteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) SFTPHomeDirectoryService(ch.cyberduck.core.sftp.SFTPHomeDirectoryService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractSFTPTest(ch.cyberduck.core.sftp.AbstractSFTPTest)

Example 18 with DefaultTouchFeature

use of ch.cyberduck.core.shared.DefaultTouchFeature in project cyberduck by iterate-ch.

the class MoveWorkerTest method testMoveToDifferentFolderCryptomator.

@Test
public void testMoveToDifferentFolderCryptomator() throws Exception {
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
    final Path source = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Path targetFolder = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
    final Path target = new Path(targetFolder, UUID.randomUUID().toString(), 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));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new SFTPWriteFeature(session)), new SFTPWriteFeature(session), cryptomator).touch(source, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    cryptomator.getFeature(session, Directory.class, new SFTPDirectoryFeature(session)).mkdir(targetFolder, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(targetFolder));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(source, target), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(target));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).delete(Arrays.asList(target, targetFolder, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Delete(ch.cyberduck.core.features.Delete) SessionPool(ch.cyberduck.core.pool.SessionPool) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) MoveWorker(ch.cyberduck.core.worker.MoveWorker) SFTPWriteFeature(ch.cyberduck.core.sftp.SFTPWriteFeature) SFTPDeleteFeature(ch.cyberduck.core.sftp.SFTPDeleteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) SFTPDirectoryFeature(ch.cyberduck.core.sftp.SFTPDirectoryFeature) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) SFTPHomeDirectoryService(ch.cyberduck.core.sftp.SFTPHomeDirectoryService) Directory(ch.cyberduck.core.features.Directory) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractSFTPTest(ch.cyberduck.core.sftp.AbstractSFTPTest) Test(org.junit.Test)

Example 19 with DefaultTouchFeature

use of ch.cyberduck.core.shared.DefaultTouchFeature in project cyberduck by iterate-ch.

the class MoveWorkerTest method testMoveFolder.

@Test
public void testMoveFolder() throws Exception {
    final Path home = new SFTPHomeDirectoryService(session).find();
    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 SFTPDirectoryFeature(session)).mkdir(folder, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(folder));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new SFTPWriteFeature(session)), new SFTPWriteFeature(session), cryptomator).touch(file, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(file));
    // rename file
    final Path fileRenamed = new Path(folder, "f1", EnumSet.of(Path.Type.file));
    new MoveWorker(Collections.singletonMap(file, fileRenamed), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback()).run(session);
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(file));
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(fileRenamed));
    // rename folder
    final Path folderRenamed = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    new MoveWorker(Collections.singletonMap(folder, folderRenamed), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback()).run(session);
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(folder));
    try {
        assertTrue(new CryptoListService(session, new SFTPListService(session), cryptomator).list(folder, new DisabledListProgressListener()).isEmpty());
    } catch (NotfoundException e) {
    // 
    }
    assertEquals(1, new CryptoListService(session, new SFTPListService(session), cryptomator).list(folderRenamed, new DisabledListProgressListener()).size());
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(folderRenamed));
    final Path fileRenamedInRenamedFolder = new Path(folderRenamed, "f1", EnumSet.of(Path.Type.file));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(fileRenamedInRenamedFolder));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).delete(Arrays.asList(fileRenamedInRenamedFolder, folderRenamed, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) CryptoListService(ch.cyberduck.core.cryptomator.features.CryptoListService) SFTPFindFeature(ch.cyberduck.core.sftp.SFTPFindFeature) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) SFTPWriteFeature(ch.cyberduck.core.sftp.SFTPWriteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) SFTPDirectoryFeature(ch.cyberduck.core.sftp.SFTPDirectoryFeature) Directory(ch.cyberduck.core.features.Directory) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) NotfoundException(ch.cyberduck.core.exception.NotfoundException) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) MoveWorker(ch.cyberduck.core.worker.MoveWorker) SFTPDeleteFeature(ch.cyberduck.core.sftp.SFTPDeleteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) SFTPListService(ch.cyberduck.core.sftp.SFTPListService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) SFTPHomeDirectoryService(ch.cyberduck.core.sftp.SFTPHomeDirectoryService) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractSFTPTest(ch.cyberduck.core.sftp.AbstractSFTPTest) Test(org.junit.Test)

Example 20 with DefaultTouchFeature

use of ch.cyberduck.core.shared.DefaultTouchFeature in project cyberduck by iterate-ch.

the class MoveWorkerTest method testMoveDirectoryOutsideVault.

@Test
public void testMoveDirectoryOutsideVault() throws Exception {
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path encryptedFolder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path encryptedFile = new Path(encryptedFolder, 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);
    cryptomator.getFeature(session, Directory.class, new SFTPDirectoryFeature(session)).mkdir(encryptedFolder, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(encryptedFolder));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new SFTPWriteFeature(session)), new SFTPWriteFeature(session), cryptomator).touch(encryptedFile, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(encryptedFile));
    // move directory outside vault
    final Path directoryRenamed = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(encryptedFolder, directoryRenamed), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(encryptedFolder));
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(encryptedFile));
    assertTrue(new SFTPFindFeature(session).find(directoryRenamed));
    final Path fileRenamed = new Path(directoryRenamed, encryptedFile.getName(), EnumSet.of(Path.Type.file));
    assertTrue(new SFTPFindFeature(session).find(fileRenamed));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).delete(Collections.singletonList(vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    new SFTPDeleteFeature(session).delete(Arrays.asList(fileRenamed, directoryRenamed), new DisabledLoginCallback(), new Delete.DisabledCallback());
    registry.clear();
}
Also used : Delete(ch.cyberduck.core.features.Delete) SFTPFindFeature(ch.cyberduck.core.sftp.SFTPFindFeature) SFTPWriteFeature(ch.cyberduck.core.sftp.SFTPWriteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) SFTPDirectoryFeature(ch.cyberduck.core.sftp.SFTPDirectoryFeature) Directory(ch.cyberduck.core.features.Directory) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) SessionPool(ch.cyberduck.core.pool.SessionPool) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) MoveWorker(ch.cyberduck.core.worker.MoveWorker) SFTPDeleteFeature(ch.cyberduck.core.sftp.SFTPDeleteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) SFTPHomeDirectoryService(ch.cyberduck.core.sftp.SFTPHomeDirectoryService) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractSFTPTest(ch.cyberduck.core.sftp.AbstractSFTPTest) Test(org.junit.Test)

Aggregations

DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)44 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)44 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)44 Path (ch.cyberduck.core.Path)44 DefaultTouchFeature (ch.cyberduck.core.shared.DefaultTouchFeature)44 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)44 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)44 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)44 IntegrationTest (ch.cyberduck.test.IntegrationTest)44 Test (org.junit.Test)44 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)42 Delete (ch.cyberduck.core.features.Delete)40 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)30 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)28 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)16 Directory (ch.cyberduck.core.features.Directory)15 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)14 CryptoListService (ch.cyberduck.core.cryptomator.features.CryptoListService)14 CryptoAttributesFeature (ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature)13 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)9