use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.
the class CryptoSFTPSingleTransferWorkerTest method testUpload.
@Test
public void testUpload() throws Exception {
final Path home = new SFTPHomeDirectoryService(session).find();
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
StringBuilder directoryname = new StringBuilder();
for (int i = 0; i < 10; i++) {
directoryname.append(new AlphanumericRandomStringService().random());
}
final Path dir1 = new Path(vault, directoryname.toString(), EnumSet.of(Path.Type.directory));
final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), directoryname.toString());
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();
localFile1.attributes().setModificationDate(1513092263154L);
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() {
@Override
public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
return new VaultCredentials("test");
}
}));
PreferencesFactory.get().setProperty("factory.vault.class", CryptoVault.class.getName());
final Host host = new Host(new TestProtocol());
final Transfer t = new UploadTransfer(host, Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>()).withOptions(new UploadFilterOptions(host).withTimestamp(true));
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 SFTPFindFeature(session), cryptomator).find(dir1));
final PathAttributes attributes1 = new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(file1);
assertEquals(1513092263000L, attributes1.getModificationDate());
assertEquals(1513092263000L, new CryptoListService(session, new SFTPListService(session), cryptomator).list(dir1, new DisabledListProgressListener()).get(file1).attributes().getModificationDate());
assertEquals(content.length, attributes1.getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new SFTPReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
assertArrayEquals(content, buffer.toByteArray());
}
final PathAttributes attributes2 = new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(file2);
assertEquals(content.length, attributes2.getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new SFTPReadFeature(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 SFTPDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localFile2.delete();
localDirectory1.delete();
}
use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.
the class CryptoDAVSingleTransferWorkerTest 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() {
@Override
public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
return new VaultCredentials("test");
}
}));
PreferencesFactory.get().setProperty("factory.vault.class", CryptoVault.class.getName());
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 DAVFindFeature(session), cryptomator).find(dir1));
assertEquals(content.length, new CryptoAttributesFeature(session, new DAVAttributesFinderFeature(session), cryptomator).find(file1).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(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 DAVAttributesFinderFeature(session), cryptomator).find(file2).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(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 DAVDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localFile2.delete();
localDirectory1.delete();
}
use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.
the class CryptoDAVSingleTransferWorkerTest method testDownload.
@Test
public void testDownload() throws Exception {
PreferencesFactory.get().setProperty("factory.vault.class", CryptoVault.class.getName());
final Path home = new DefaultHomeFinderService(session).find();
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
final CryptoVault cryptomator = new CryptoVault(vault);
cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback() {
@Override
public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
return new VaultCredentials("test");
}
}));
final Path dir1 = cryptomator.getFeature(session, Directory.class, new DAVDirectoryFeature(session)).mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final FileHeader header = cryptomator.getFileHeaderCryptor().create();
final byte[] content = RandomUtils.nextBytes(62768);
final TransferStatus status = new TransferStatus();
status.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
status.setNonces(new RotatingNonceGenerator(cryptomator.numberOfChunks(content.length)));
final StatusOutputStream<Void> out = new CryptoWriteFeature<>(session, new DAVWriteFeature(session), cryptomator).write(file1, status, new DisabledConnectionCallback());
IOUtils.write(content, out);
out.close();
final Local localFile1 = new Local(localDirectory1, file1.getName());
final Transfer t = new DownloadTransfer(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));
cryptomator.getFeature(session, Delete.class, new DAVDeleteFeature(session)).delete(Arrays.asList(file1, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localDirectory1.delete();
}
use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.
the class CryptoLocalSingleTransferWorkerTest method testUpload.
@Test
public void testUpload() throws Exception {
final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname()));
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path home = new LocalHomeFinderFeature().find();
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
StringBuilder directoryname = new StringBuilder();
for (int i = 0; i < 10; i++) {
directoryname.append(new AlphanumericRandomStringService().random());
}
final Path dir1 = new Path(vault, directoryname.toString(), EnumSet.of(Path.Type.directory));
final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), directoryname.toString());
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() {
@Override
public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
return new VaultCredentials("test");
}
}));
PreferencesFactory.get().setProperty("factory.vault.class", CryptoVault.class.getName());
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 LocalFindFeature(session), cryptomator).find(dir1));
assertEquals(content.length, new CryptoAttributesFeature(session, new LocalAttributesFinderFeature(session), cryptomator).find(file1).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new LocalReadFeature(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 LocalAttributesFinderFeature(session), cryptomator).find(file2).getSize());
{
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
final InputStream in = new CryptoReadFeature(session, new LocalReadFeature(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 LocalDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localFile2.delete();
localDirectory1.delete();
}
use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.
the class CryptoSwiftSingleTransferWorkerTest method testUpload.
@Test
public void testUpload() throws Exception {
final Path home = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory));
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 SwiftFindFeature(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 SwiftReadFeature(session, new SwiftRegionService(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 SwiftReadFeature(session, new SwiftRegionService(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 SwiftDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
localFile1.delete();
localFile2.delete();
localDirectory1.delete();
}
Aggregations