Search in sources :

Example 76 with DisabledProgressListener

use of ch.cyberduck.core.DisabledProgressListener 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 77 with DisabledProgressListener

use of ch.cyberduck.core.DisabledProgressListener 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)

Example 78 with DisabledProgressListener

use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.

the class MoveWorkerTest method testMoveFileOutsideVault.

@Test
public void testMoveFileOutsideVault() 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 clearFolder = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    new SFTPDirectoryFeature(session).mkdir(clearFolder, new TransferStatus());
    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 file outside vault
    final Path fileRenamed = new Path(clearFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(encryptedFile, fileRenamed), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(encryptedFile));
    assertTrue(new SFTPFindFeature(session).find(fileRenamed));
    cryptomator.getFeature(session, Delete.class, new SFTPDeleteFeature(session)).delete(Arrays.asList(encryptedFolder, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    new SFTPDeleteFeature(session).delete(Arrays.asList(fileRenamed, clearFolder), 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)

Example 79 with DisabledProgressListener

use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.

the class SFTPSessionTest method testUsernameChangeReconnect.

@Test
@Ignore
public void testUsernameChangeReconnect() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials("u1", "p1"));
    final Session session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    final AtomicBoolean change = new AtomicBoolean();
    final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Local select(final Local identity) throws LoginCanceledException {
            return new NullLocal("k");
        }

        @Override
        public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) {
            if (change.get()) {
                assertEquals("Change of username or service not allowed: (u1,ssh-connection) -> (jenkins,ssh-connection). Please contact your web hosting service provider for assistance.", reason);
                return null;
            } else {
                assertEquals("Login failed", title);
                // assertEquals("Too many authentication failures for u1. Please contact your web hosting service provider for assistance.", reason);
                // assertEquals("Exhausted available authentication methods. Please contact your web hosting service provider for assistance.", reason);
                change.set(true);
                return new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"));
            }
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    login.connect(session, new DisabledCancelCallback());
    assertTrue(change.get());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) LoginOptions(ch.cyberduck.core.LoginOptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) NullLocal(ch.cyberduck.core.NullLocal) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) Session(ch.cyberduck.core.Session) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 80 with DisabledProgressListener

use of ch.cyberduck.core.DisabledProgressListener in project cyberduck by iterate-ch.

the class SFTPSessionTest method testValidateNoValidCredentials.

@Test(expected = LoginCanceledException.class)
public void testValidateNoValidCredentials() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch");
    final Session session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    final AtomicBoolean change = new AtomicBoolean();
    final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) throws LoginCanceledException {
            assertEquals("Login test.cyberduck.ch", title);
            assertEquals("Login test.cyberduck.ch – SFTP with username and password. Select the private key in PEM or PuTTY format. No login credentials could be found in the Keychain.", reason);
            change.set(true);
            throw new LoginCanceledException();
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    try {
        login.check(session, new DisabledCancelCallback());
    } catch (LoginCanceledException e) {
        assertTrue(change.get());
        throw e;
    }
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) LoginOptions(ch.cyberduck.core.LoginOptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) Session(ch.cyberduck.core.Session) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)166 Test (org.junit.Test)147 Host (ch.cyberduck.core.Host)135 Path (ch.cyberduck.core.Path)128 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)103 TestProtocol (ch.cyberduck.core.TestProtocol)95 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)94 NullSession (ch.cyberduck.core.NullSession)68 IntegrationTest (ch.cyberduck.test.IntegrationTest)65 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)59 NullLocal (ch.cyberduck.core.NullLocal)49 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)48 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)48 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)48 Credentials (ch.cyberduck.core.Credentials)43 Delete (ch.cyberduck.core.features.Delete)42 Local (ch.cyberduck.core.Local)40 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)39 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)36 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)34