use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.
the class CloudFrontDistributionConfigurationTest method testGetName.
@Test
public void testGetName() {
final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname()));
final DistributionConfiguration configuration = new CloudFrontDistributionConfiguration(session, new DisabledX509TrustManager(), new DefaultX509KeyManager());
assertEquals("Amazon CloudFront", configuration.getName());
}
use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.
the class CustomOriginCloudFrontDistributionConfigurationTest method testReadMissingCredentials.
@Test(expected = LoginCanceledException.class)
public void testReadMissingCredentials() throws Exception {
final Host bookmark = new Host(new TestProtocol(), "myhost.localdomain");
final CustomOriginCloudFrontDistributionConfiguration configuration = new CustomOriginCloudFrontDistributionConfiguration(bookmark, new DefaultX509TrustManager(), new DefaultX509KeyManager());
final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
configuration.read(container, Distribution.CUSTOM, new DisabledLoginCallback());
}
use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.
the class S3SingleTransferWorkerTest method testTransferredSizeRepeat.
@Test
public void testTransferredSizeRepeat() throws Exception {
final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
// Minimum multipart upload size
final byte[] content = new byte[6 * 1024 * 1024];
new Random().nextBytes(content);
final OutputStream out = local.getOutputStream(false);
IOUtils.write(content, out);
out.close();
final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new S3Protocol())));
final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/S3 (HTTPS).cyberduckprofile"));
final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials(System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")));
final AtomicBoolean failed = new AtomicBoolean();
final S3Session session = new S3Session(host, new DefaultX509TrustManager(), new DefaultX509KeyManager()) {
@Override
@SuppressWarnings("unchecked")
public <T> T _getFeature(final Class<T> type) {
if (type == Upload.class) {
return (T) new S3MultipartUploadService(this, new S3WriteFeature(this), 5 * 1024L * 1024L, 5) {
@Override
protected InputStream decorate(final InputStream in, final MessageDigest digest) {
if (failed.get()) {
// Second attempt successful
return in;
}
return new CountingInputStream(in) {
@Override
protected void beforeRead(final int n) throws IOException {
super.beforeRead(n);
if (this.getByteCount() >= 1024L * 1024L) {
failed.set(true);
throw new SocketTimeoutException();
}
}
};
}
};
}
return super._getFeature(type);
}
};
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final Path test = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Transfer t = new UploadTransfer(session.getHost(), test, local);
final BytecountStreamListener counter = new BytecountStreamListener();
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(), counter, new DisabledLoginCallback(), new DisabledNotificationService()) {
}.run(session));
local.delete();
assertTrue(t.isComplete());
assertEquals(content.length, new S3AttributesFinderFeature(session).find(test).getSize());
assertEquals(content.length, counter.getRecv(), 0L);
assertEquals(content.length, counter.getSent(), 0L);
assertTrue(failed.get());
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.
the class SpectraAttributesFinderFeatureTest method testFindPlaceholder.
@Test
public void testFindPlaceholder() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new S3DirectoryFeature(session, new S3WriteFeature(session)).mkdir(new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final PathAttributes attributes = new SpectraAttributesFinderFeature(session).find(test);
new SpectraDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertEquals(0L, attributes.getSize());
assertEquals(Checksum.parse("d41d8cd98f00b204e9800998ecf8427e"), attributes.getChecksum());
// Missing support for modification date
assertEquals(-1L, attributes.getModificationDate());
}
use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.
the class SpectraAttributesFinderFeatureTest method testFindBucket.
@Test
public void testFindBucket() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final PathAttributes attributes = new SpectraAttributesFinderFeature(session).find(container);
assertEquals(-1L, attributes.getSize());
assertNull(attributes.getRegion());
assertEquals(EnumSet.of(Path.Type.directory, Path.Type.volume), container.getType());
}
Aggregations