Search in sources :

Example 1 with DisabledX509TrustManager

use of ch.cyberduck.core.ssl.DisabledX509TrustManager in project cyberduck by iterate-ch.

the class DefaultSessionPoolTest method testConnectRefuse.

@Test(expected = ConnectionRefusedException.class)
public void testConnectRefuse() throws Exception {
    final DefaultSessionPool pool = new DefaultSessionPool(new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) throws BackgroundException {
            throw new ConnectionRefusedException("t", new RuntimeException());
        }
    }, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), new Host(new TestProtocol(), "t"));
    pool.borrow(BackgroundActionState.running);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) ConnectionRefusedException(ch.cyberduck.core.exception.ConnectionRefusedException) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) Test(org.junit.Test)

Example 2 with DisabledX509TrustManager

use of ch.cyberduck.core.ssl.DisabledX509TrustManager in project cyberduck by iterate-ch.

the class DefaultSessionPoolTest method testCheckReconnectApplicationFailure.

@Test
public void testCheckReconnectApplicationFailure() throws Exception {
    final AtomicBoolean interrupt = new AtomicBoolean();
    final Host bookmark = new Host(new TestProtocol());
    final TestLoginConnectionService connect = new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) {
            return true;
        }
    };
    final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {

        @Override
        public Session create() {
            return new NullSession(bookmark) {

                @Override
                public void interrupt() throws BackgroundException {
                    interrupt.set(true);
                    super.interrupt();
                }
            };
        }
    }));
    final Session<?> session = pool.borrow(BackgroundActionState.running);
    pool.release(session, new BackgroundException("m", "d"));
    assertFalse(interrupt.get());
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 3 with DisabledX509TrustManager

use of ch.cyberduck.core.ssl.DisabledX509TrustManager in project cyberduck by iterate-ch.

the class DefaultSessionPoolTest method testCheckReconnectSocketFailure.

@Test
public void testCheckReconnectSocketFailure() throws Exception {
    final AtomicBoolean interrupt = new AtomicBoolean();
    final Host bookmark = new Host(new TestProtocol());
    final TestLoginConnectionService connect = new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) {
            return true;
        }
    };
    final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {

        @Override
        public Session create() {
            return new NullSession(bookmark) {

                @Override
                public void interrupt() throws BackgroundException {
                    interrupt.set(true);
                    super.interrupt();
                }
            };
        }
    }));
    final Session<?> session = pool.borrow(BackgroundActionState.running);
    pool.release(session, new BackgroundException("m", new SocketException("m")));
    assertTrue(interrupt.get());
}
Also used : SocketException(java.net.SocketException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 4 with DisabledX509TrustManager

use of ch.cyberduck.core.ssl.DisabledX509TrustManager in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testAwait.

@Test
public void testAwait() throws Exception {
    final Host host = new Host(new TestProtocol(), "localhost", new Credentials("u", "p"));
    final Transfer transfer = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host), SessionPool.DISCONNECTED, transfer, new TransferOptions(), new TransferSpeedometer(transfer), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    int workers = 1000;
    final CountDownLatch entry = new CountDownLatch(workers);
    for (int i = 0; i < workers; i++) {
        worker.submit(new TransferWorker.TransferCallable() {

            @Override
            public TransferStatus call() {
                entry.countDown();
                return new TransferStatus().complete();
            }
        });
    }
    worker.await();
    assertEquals(0, entry.getCount());
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) CountDownLatch(java.util.concurrent.CountDownLatch) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test)

Example 5 with DisabledX509TrustManager

use of ch.cyberduck.core.ssl.DisabledX509TrustManager in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testConcurrentSessions.

@Test
public void testConcurrentSessions() throws Exception {
    final int files = 20;
    final int connections = 3;
    final Set<Path> transferred = ConcurrentHashMap.newKeySet();
    final List<TransferItem> list = new ArrayList<TransferItem>();
    for (int i = 1; i <= files; i++) {
        list.add(new TransferItem(new Path("/t" + i, EnumSet.of(Path.Type.file)), new NullLocal("/t" + i)));
    }
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final Transfer t = new DownloadTransfer(host, list) {

        @Override
        public void transfer(final Session<?> source, final Session<?> destination, final Path file, final Local local, final TransferOptions options, final TransferStatus overall, final TransferStatus segment, final ConnectionCallback connectionCallback, final ProgressListener listener, final StreamListener streamListener) {
            assertNotNull(source);
            transferred.add(file);
        }

        @Override
        public AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
            return new AbstractDownloadFilter(new DisabledDownloadSymlinkResolver(), source, null) {

                @Override
                public boolean accept(final Path file, final Local local, final TransferStatus parent) {
                    assertFalse(transferred.contains(file));
                    return true;
                }

                @Override
                public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) {
                    assertFalse(transferred.contains(file));
                    return new TransferStatus();
                }

                @Override
                public void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener) {
                    assertFalse(transferred.contains(file));
                }

                @Override
                public void complete(final Path file, final Local local, final TransferOptions options, final TransferStatus status, final ProgressListener listener) {
                    assertTrue(transferred.contains(file));
                }
            };
        }
    };
    final LoginConnectionService connection = new TestLoginConnectionService();
    final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host);
    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 DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    pool.withMaxTotal(connections);
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    assertTrue(worker.run(session));
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
    for (int i = 1; i <= files; i++) {
        assertTrue(transferred.contains(new Path("/t" + i, EnumSet.of(Path.Type.file))));
    }
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TransferAction(ch.cyberduck.core.transfer.TransferAction) ArrayList(java.util.ArrayList) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) StreamListener(ch.cyberduck.core.io.StreamListener) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) AbstractDownloadFilter(ch.cyberduck.core.transfer.download.AbstractDownloadFilter) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test)

Aggregations

DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)147 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)145 Test (org.junit.Test)141 Host (ch.cyberduck.core.Host)111 IntegrationTest (ch.cyberduck.test.IntegrationTest)110 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)89 Credentials (ch.cyberduck.core.Credentials)84 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)80 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)79 Path (ch.cyberduck.core.Path)79 Scheme (ch.cyberduck.core.Scheme)48 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)45 Delete (ch.cyberduck.core.features.Delete)37 TransferItem (ch.cyberduck.core.transfer.TransferItem)25 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)24 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)22 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)20 Local (ch.cyberduck.core.Local)19 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)17 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16