Search in sources :

Example 36 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class B2DirectoryFeatureTest method testMakeDirectoryLongFilenameEncrypted.

@Test
public void testMakeDirectoryLongFilenameEncrypted() throws Exception {
    assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
    final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final CryptoVault cryptomator = new CryptoVault(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)));
    final Path vault = cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
    final Path test = cryptomator.getFeature(session, Directory.class, new B2DirectoryFeature(session, fileid)).mkdir(new Path(vault, new AlphanumericRandomStringService(130).random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    cryptomator.getFeature(session, Delete.class, new B2DeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) B2DirectoryFeature(ch.cyberduck.core.b2.B2DirectoryFeature) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Directory(ch.cyberduck.core.features.Directory) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 37 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class SessionBackgroundActionTest method testGetExceptionConnectionCanceledException.

@Test
public void testGetExceptionConnectionCanceledException() {
    SessionBackgroundAction<Void> a = new SessionBackgroundAction<Void>(new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new DisabledAlertCallback(), new DisabledProgressListener()) {

        @Override
        public Void run(final Session<?> session) throws BackgroundException {
            throw new ConnectionCanceledException();
        }
    };
    try {
        a.call();
        fail();
    } catch (BackgroundException e) {
    // Ignore
    }
    assertFalse(a.hasFailed());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 38 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry 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 39 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry 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 40 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class CryptoDropboxSingleTransferWorkerTest method testUpload.

@Test
public void testUpload() 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 dir1 = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    new DefaultLocalDirectoryFeature().mkdir(localDirectory1);
    final byte[] content = RandomUtils.nextBytes(62768);
    final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile1 = new Local(localDirectory1, file1.getName());
    final OutputStream out1 = localFile1.getOutputStream(false);
    IOUtils.write(content, out1);
    out1.close();
    final Path file2 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile2 = new Local(localDirectory1, file2.getName());
    final OutputStream out2 = localFile2.getOutputStream(false);
    IOUtils.write(content, out2);
    out2.close();
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Transfer t = new UploadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>());
    assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    assertTrue(new CryptoFindFeature(session, new DropboxFindFeature(session), cryptomator).find(dir1));
    assertEquals(content.length, new CryptoAttributesFeature(session, new DefaultAttributesFinderFeature(session), cryptomator).find(file1).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    assertEquals(content.length, new CryptoAttributesFeature(session, new DefaultAttributesFinderFeature(session), cryptomator).find(file2).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    cryptomator.getFeature(session, Delete.class, new DropboxDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    localFile1.delete();
    localFile2.delete();
    localDirectory1.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) SingleTransferWorker(ch.cyberduck.core.worker.SingleTransferWorker) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultLocalDirectoryFeature(ch.cyberduck.core.local.DefaultLocalDirectoryFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) DropboxReadFeature(ch.cyberduck.core.dropbox.DropboxReadFeature) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DropboxDeleteFeature(ch.cyberduck.core.dropbox.DropboxDeleteFeature) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) Host(ch.cyberduck.core.Host) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) TransferItem(ch.cyberduck.core.transfer.TransferItem) DropboxFindFeature(ch.cyberduck.core.dropbox.DropboxFindFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractDropboxTest(ch.cyberduck.core.AbstractDropboxTest) Test(org.junit.Test)

Aggregations

DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)169 Test (org.junit.Test)169 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)157 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)148 Path (ch.cyberduck.core.Path)146 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)145 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)143 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)143 IntegrationTest (ch.cyberduck.test.IntegrationTest)143 Delete (ch.cyberduck.core.features.Delete)136 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)135 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)123 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)72 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)70 CryptoAttributesFeature (ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature)62 CryptoReadFeature (ch.cyberduck.core.cryptomator.features.CryptoReadFeature)50 StreamCopier (ch.cyberduck.core.io.StreamCopier)50 Directory (ch.cyberduck.core.features.Directory)49 InputStream (java.io.InputStream)47 DefaultTouchFeature (ch.cyberduck.core.shared.DefaultTouchFeature)44