Search in sources :

Example 6 with DisabledTranscriptListener

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

the class TransferBackgroundActionTest method testResumeOnRetryWithException.

@Test
public void testResumeOnRetryWithException() {
    final AtomicBoolean alert = new AtomicBoolean();
    final AbstractController controller = new AbstractController() {

        @Override
        public void invoke(final MainAction runnable, final boolean wait) {
            runnable.run();
        }
    };
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final TransferOptions options = new TransferOptions();
    final TransferBackgroundAction action = new TransferBackgroundAction(controller, new DefaultSessionPool(new TestLoginConnectionService(), new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host) {

        @Override
        public Session<?> borrow(final BackgroundActionState callback) throws BackgroundException {
            throw new ConnectionRefusedException("d", new SocketException());
        }
    }, SessionPool.DISCONNECTED, new TransferAdapter(), new DownloadTransfer(host, Collections.singletonList(new TransferItem(new Path("/home/test", EnumSet.of(Path.Type.file)), new NullLocal("/t")))), options) {

        @Override
        public boolean alert(final BackgroundException failure) {
            final boolean alerted = alert.get();
            alert.set(true);
            return !alerted;
        }
    };
    assertFalse(alert.get());
    // Connect, prepare and run
    new BackgroundCallable<Boolean>(action, controller).call();
    assertTrue(alert.get());
    assertTrue(action.hasFailed());
// assertTrue(options.resumeRequested);
}
Also used : SocketException(java.net.SocketException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) ConnectionRefusedException(ch.cyberduck.core.exception.ConnectionRefusedException) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) NullLocal(ch.cyberduck.core.NullLocal) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Path(ch.cyberduck.core.Path) TransferAdapter(ch.cyberduck.core.transfer.TransferAdapter) Host(ch.cyberduck.core.Host) AbstractController(ch.cyberduck.core.AbstractController) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) TransferItem(ch.cyberduck.core.transfer.TransferItem) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) NullTransferSession(ch.cyberduck.core.NullTransferSession) Test(org.junit.Test)

Example 7 with DisabledTranscriptListener

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

the class TransferBackgroundActionTest method testCopyBetweenHosts.

@Test
public void testCopyBetweenHosts() throws Exception {
    final Session session = new NullTransferSession(new Host(new TestProtocol(), "test.cyberduck.ch"));
    final Session destination = new NullTransferSession(new Host(new TestProtocol(), "test.cyberduck.ch"));
    final Path directory = new Path("/home/jenkins/transfer", EnumSet.of(Path.Type.directory));
    final Path test = new Path(directory, "test", EnumSet.of(Path.Type.file));
    test.attributes().setSize(0L);
    final Path copy = new Path(new Path("/transfer", EnumSet.of(Path.Type.directory)), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Transfer t = new CopyTransfer(session.getHost(), destination.getHost(), Collections.singletonMap(test, copy)) {

        @Override
        public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) {
            return TransferAction.overwrite;
        }
    };
    final AbstractController controller = new AbstractController() {

        @Override
        public void invoke(final MainAction runnable, final boolean wait) {
            runnable.run();
        }
    };
    final AtomicBoolean start = new AtomicBoolean();
    final AtomicBoolean stop = new AtomicBoolean();
    final TransferBackgroundAction action = new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), session, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new StatelessSessionPool(new TestLoginConnectionService(), destination, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new TransferListener() {

        @Override
        public void transferDidStart(final Transfer transfer) {
            assertEquals(t, transfer);
            start.set(true);
        }

        @Override
        public void transferDidStop(final Transfer transfer) {
            assertEquals(t, transfer);
            stop.set(true);
        }

        @Override
        public void transferDidProgress(final Transfer transfer, final TransferProgress status) {
        // 
        }
    }, t, new TransferOptions());
    action.prepare();
    action.call();
    action.finish();
    assertFalse(action.hasFailed());
    assertTrue(start.get());
    assertTrue(stop.get());
    assertTrue(t.isComplete());
    assertNotNull(t.getTimestamp());
}
Also used : Path(ch.cyberduck.core.Path) TransferListener(ch.cyberduck.core.transfer.TransferListener) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) AbstractController(ch.cyberduck.core.AbstractController) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TransferProgress(ch.cyberduck.core.transfer.TransferProgress) NullTransferSession(ch.cyberduck.core.NullTransferSession) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) CopyTransfer(ch.cyberduck.core.transfer.CopyTransfer) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CopyTransfer(ch.cyberduck.core.transfer.CopyTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) ListProgressListener(ch.cyberduck.core.ListProgressListener) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) NullTransferSession(ch.cyberduck.core.NullTransferSession) TransferPrompt(ch.cyberduck.core.transfer.TransferPrompt) Test(org.junit.Test)

Example 8 with DisabledTranscriptListener

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

the class FreenetAuthenticatedUrlProvider method toUrl.

@Override
public DescriptiveUrl toUrl(final Host bookmark) {
    try {
        // Run password flow
        final TokenResponse response;
        try {
            final Host target = new Host(new DAVSSLProtocol(), "oauth.freenet.de");
            final X509TrustManager trust = new KeychainX509TrustManager(new DisabledCertificateTrustCallback(), new DefaultTrustManagerHostnameCallback(target), CertificateStoreFactory.get());
            final X509KeyManager key = new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), target, CertificateStoreFactory.get());
            final CloseableHttpClient client = new HttpConnectionPoolBuilder(target, new ThreadLocalHostnameDelegatingTrustManager(trust, target.getHostname()), key, ProxyFactory.get()).build(ProxyFactory.get().find(new ProxyHostUrlProvider().get(target)), new DisabledTranscriptListener(), new DisabledLoginCallback()).setUserAgent(new FreenetUserAgentProvider().get()).build();
            final String username = bookmark.getCredentials().getUsername();
            final String password;
            if (StringUtils.isBlank(bookmark.getCredentials().getPassword())) {
                password = PasswordStoreFactory.get().findLoginPassword(bookmark);
            } else {
                password = bookmark.getCredentials().getPassword();
            }
            response = new PasswordTokenRequest(new ApacheHttpTransport(client), new GsonFactory(), new GenericUrl("https://oauth.freenet.de/oauth/token"), username, password).setClientAuthentication(new BasicAuthentication("desktop_client", "6LIGIHuOSkznLomu5xw0EPPBJOXb2jLp")).setRequestInitializer(new UserAgentHttpRequestInitializer(new FreenetUserAgentProvider())).set("world", new HostPreferences(bookmark).getProperty("world")).set("webLogin", Boolean.TRUE).execute();
            final FreenetTemporaryLoginResponse login = this.getLoginSession(client, response.getAccessToken());
            return new DescriptiveUrl(URI.create(login.urls.login), DescriptiveUrl.Type.authenticated);
        } catch (IOException e) {
            throw new HttpExceptionMappingService().map(e);
        }
    } catch (BackgroundException e) {
        log.warn(String.format("Failure %s retrieving authenticated URL for %s", e, bookmark));
        return DescriptiveUrl.EMPTY;
    }
}
Also used : UserAgentHttpRequestInitializer(ch.cyberduck.core.http.UserAgentHttpRequestInitializer) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) ProxyHostUrlProvider(ch.cyberduck.core.proxy.ProxyHostUrlProvider) GenericUrl(com.google.api.client.http.GenericUrl) DAVSSLProtocol(ch.cyberduck.core.dav.DAVSSLProtocol) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) HttpExceptionMappingService(ch.cyberduck.core.http.HttpExceptionMappingService) HttpConnectionPoolBuilder(ch.cyberduck.core.http.HttpConnectionPoolBuilder) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) X509KeyManager(ch.cyberduck.core.ssl.X509KeyManager) DisabledCertificateTrustCallback(ch.cyberduck.core.DisabledCertificateTrustCallback) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) GsonFactory(com.google.api.client.json.gson.GsonFactory) Host(ch.cyberduck.core.Host) IOException(java.io.IOException) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) HostPreferences(ch.cyberduck.core.preferences.HostPreferences) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) TokenResponse(com.google.api.client.auth.oauth2.TokenResponse) X509TrustManager(ch.cyberduck.core.ssl.X509TrustManager) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) ThreadLocalHostnameDelegatingTrustManager(ch.cyberduck.core.ssl.ThreadLocalHostnameDelegatingTrustManager) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) BasicAuthentication(com.google.api.client.http.BasicAuthentication) PasswordTokenRequest(com.google.api.client.auth.oauth2.PasswordTokenRequest) ApacheHttpTransport(com.google.api.client.http.apache.v2.ApacheHttpTransport) BackgroundException(ch.cyberduck.core.exception.BackgroundException)

Example 9 with DisabledTranscriptListener

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

the class SFTPCompressFeatureTest method testArchive.

@Test
@Ignore
public void testArchive() throws Exception {
    final SFTPCompressFeature feature = new SFTPCompressFeature(session);
    for (Archive archive : Archive.getKnownArchives()) {
        final Path workdir = new SFTPHomeDirectoryService(session).find();
        final Path test = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
        session.getFeature(Touch.class).touch(test, new TransferStatus());
        feature.archive(archive, workdir, Collections.singletonList(test), new ProgressListener() {

            @Override
            public void message(final String message) {
            // 
            }
        }, new DisabledTranscriptListener());
        assertTrue(new SFTPFindFeature(session).find(archive.getArchive(Collections.singletonList(test))));
        new SFTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
        assertFalse(new SFTPFindFeature(session).find(test));
        feature.unarchive(archive, archive.getArchive(Collections.singletonList(test)), new ProgressListener() {

            @Override
            public void message(final String message) {
            // 
            }
        }, new DisabledTranscriptListener());
        assertTrue(new SFTPFindFeature(session).find(test));
        new SFTPDeleteFeature(session).delete(Collections.singletonList(archive.getArchive(Collections.singletonList(test))), new DisabledLoginCallback(), new Delete.DisabledCallback());
        new SFTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) Archive(ch.cyberduck.core.Archive) Touch(ch.cyberduck.core.features.Touch) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) ProgressListener(ch.cyberduck.core.ProgressListener) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 10 with DisabledTranscriptListener

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

the class AWSSessionCredentialsRetrieverTest method testParse.

@Test
public void testParse() throws Exception {
    final Credentials c = new AWSSessionCredentialsRetriever(new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DisabledTranscriptListener(), "http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access").parse(IOUtils.toInputStream("{\n" + "  \"Code\" : \"Success\",\n" + "  \"LastUpdated\" : \"2012-04-26T16:39:16Z\",\n" + "  \"Type\" : \"AWS-HMAC\",\n" + "  \"AccessKeyId\" : \"AKIAIOSFODNN7EXAMPLE\",\n" + "  \"SecretAccessKey\" : \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n" + "  \"Token\" : \"token\",\n" + "  \"Expiration\" : \"2012-04-27T22:39:16Z\"\n" + "}", Charset.defaultCharset()));
    assertEquals("AKIAIOSFODNN7EXAMPLE", c.getUsername());
    assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", c.getPassword());
    assertEquals("token", c.getToken());
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Credentials(ch.cyberduck.core.Credentials) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) Test(org.junit.Test)

Aggregations

DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)18 Test (org.junit.Test)16 Host (ch.cyberduck.core.Host)15 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)14 TestLoginConnectionService (ch.cyberduck.core.TestLoginConnectionService)14 TestProtocol (ch.cyberduck.core.TestProtocol)14 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)14 NullSession (ch.cyberduck.core.NullSession)12 BackgroundException (ch.cyberduck.core.exception.BackgroundException)11 Session (ch.cyberduck.core.Session)9 StatelessSessionPool (ch.cyberduck.core.pool.StatelessSessionPool)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)6 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)6 CancelCallback (ch.cyberduck.core.threading.CancelCallback)5 AbstractController (ch.cyberduck.core.AbstractController)4 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)4 Path (ch.cyberduck.core.Path)4 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)4 TransferOptions (ch.cyberduck.core.transfer.TransferOptions)4