Search in sources :

Example 1 with FTPWriteFeature

use of ch.cyberduck.core.ftp.FTPWriteFeature in project cyberduck by iterate-ch.

the class FTPListServiceTest method testListCryptomator.

@Test
public void testListCryptomator() throws Exception {
    final Path home = new DefaultHomeFinderService(session).find();
    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));
    assertTrue(new CryptoListService(session, new FTPListService(session, null, null), cryptomator).list(vault, new DisabledListProgressListener()).isEmpty());
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new FTPWriteFeature(session)), new FTPWriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertEquals(test, new CryptoListService(session, new FTPListService(session, null, null), cryptomator).list(vault, new DisabledListProgressListener()).get(0));
    cryptomator.getFeature(session, Delete.class, new FTPDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) CryptoListService(ch.cyberduck.core.cryptomator.features.CryptoListService) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) FTPListService(ch.cyberduck.core.ftp.list.FTPListService) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 2 with FTPWriteFeature

use of ch.cyberduck.core.ftp.FTPWriteFeature in project cyberduck by iterate-ch.

the class FTPMoveFeatureTest method testMove.

@Test
public void testMove() throws Exception {
    final Path home = new DefaultHomeFinderService(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 FTPDirectoryFeature(session)).mkdir(folder, new TransferStatus());
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new FTPWriteFeature(session)), new FTPWriteFeature(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 FTPMoveFeature(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 DefaultFindFeature(session), cryptomator).find(file));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(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 DefaultFindFeature(session), cryptomator).find(folder));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(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 FTPDeleteFeature(session)).delete(Arrays.asList(fileRenamedInRenamedFolder, folderRenamed, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) FTPDirectoryFeature(ch.cyberduck.core.ftp.FTPDirectoryFeature) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) FTPMoveFeature(ch.cyberduck.core.ftp.FTPMoveFeature) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) Move(ch.cyberduck.core.features.Move) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Directory(ch.cyberduck.core.features.Directory) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 3 with FTPWriteFeature

use of ch.cyberduck.core.ftp.FTPWriteFeature in project cyberduck by iterate-ch.

the class FTPTouchFeatureTest method testTouchLongFilenameEncryptedDefaultFeature.

@Test
public void testTouchLongFilenameEncryptedDefaultFeature() throws Exception {
    assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService(130).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));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new FTPWriteFeature(session)), new FTPWriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new FTPDeleteFeature(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) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 4 with FTPWriteFeature

use of ch.cyberduck.core.ftp.FTPWriteFeature in project cyberduck by iterate-ch.

the class FTPTouchFeatureTest method testTouchLongFilenameEncrypted.

@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService(130).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));
    new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new FTPWriteFeature(session)), new FTPWriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new FTPDeleteFeature(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) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 5 with FTPWriteFeature

use of ch.cyberduck.core.ftp.FTPWriteFeature in project cyberduck by iterate-ch.

the class FTPConcurrentTransferWorkerTest method testTransferredSizeRepeat.

@Test
public void testTransferredSizeRepeat() throws Exception {
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = new byte[98305];
    new Random().nextBytes(content);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(content, out);
    out.close();
    final AtomicBoolean failed = new AtomicBoolean();
    final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Transfer t = new UploadTransfer(session.getHost(), test, local);
    final BytecountStreamListener counter = new BytecountStreamListener();
    final LoginConnectionService connect = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            return new Credentials("test", "test");
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), session.getHost(), new GenericObjectPool<>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), session.getHost(), new DefaultVaultRegistry(new DisabledPasswordCallback())) {

        @Override
        public Session create() {
            return new FTPSession(session.getHost()) {

                final FTPWriteFeature write = new FTPWriteFeature(this) {

                    @Override
                    public StatusOutputStream<Void> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
                        final StatusOutputStream<Void> proxy = super.write(file, status, callback);
                        if (failed.get()) {
                            // Second attempt successful
                            return proxy;
                        }
                        return new VoidStatusOutputStream(new CountingOutputStream(proxy) {

                            @Override
                            protected void afterWrite(final int n) throws IOException {
                                super.afterWrite(n);
                                if (this.getByteCount() >= 42768L) {
                                    // Buffer size
                                    assertEquals(32768L, counter.getSent());
                                    failed.set(true);
                                    throw new SocketTimeoutException();
                                }
                            }
                        }) {

                            @Override
                            public Void getStatus() throws BackgroundException {
                                return proxy.getStatus();
                            }
                        };
                    }
                };

                @Override
                @SuppressWarnings("unchecked")
                public <T> T _getFeature(final Class<T> type) {
                    if (type == Write.class) {
                        return (T) write;
                    }
                    return super._getFeature(type);
                }
            };
        }
    }));
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool, SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledConnectionCallback(), new DisabledProgressListener(), counter, new DisabledNotificationService());
    assertTrue(worker.run(session));
    local.delete();
    assertTrue(t.isComplete());
    assertEquals(content.length, new DefaultAttributesFinderFeature(session).find(test).getSize());
    assertEquals(content.length, counter.getRecv(), 0L);
    assertEquals(content.length, counter.getSent(), 0L);
    assertTrue(failed.get());
    new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) FTPSession(ch.cyberduck.core.ftp.FTPSession) OutputStream(java.io.OutputStream) VoidStatusOutputStream(ch.cyberduck.core.io.VoidStatusOutputStream) CountingOutputStream(org.apache.commons.io.output.CountingOutputStream) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) CountingOutputStream(org.apache.commons.io.output.CountingOutputStream) Random(java.util.Random) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) VoidStatusOutputStream(ch.cyberduck.core.io.VoidStatusOutputStream) VoidStatusOutputStream(ch.cyberduck.core.io.VoidStatusOutputStream) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SocketTimeoutException(java.net.SocketTimeoutException) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) PooledSessionFactory(ch.cyberduck.core.pool.PooledSessionFactory) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) TransferItem(ch.cyberduck.core.transfer.TransferItem) BackgroundException(ch.cyberduck.core.exception.BackgroundException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TransferAction(ch.cyberduck.core.transfer.TransferAction) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Test(org.junit.Test) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Aggregations

Delete (ch.cyberduck.core.features.Delete)7 AbstractFTPTest (ch.cyberduck.core.ftp.AbstractFTPTest)7 FTPDeleteFeature (ch.cyberduck.core.ftp.FTPDeleteFeature)7 FTPWriteFeature (ch.cyberduck.core.ftp.FTPWriteFeature)7 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)7 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)7 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)7 Test (org.junit.Test)7 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)6 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)6 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)6 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)6 Path (ch.cyberduck.core.Path)6 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)6 IntegrationTest (ch.cyberduck.test.IntegrationTest)6 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)5 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)5 DefaultTouchFeature (ch.cyberduck.core.shared.DefaultTouchFeature)5 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)2 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)2