use of ch.cyberduck.core.LoginConnectionService in project cyberduck by iterate-ch.
the class GoogleStorageSessionTest method testConnect.
@Test
public void testConnect() throws Exception {
session.close();
final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore() {
@Override
public String getPassword(final Scheme scheme, final int port, final String hostname, final String user) {
if (user.equals("Google Cloud Storage (api-project-408246103372) OAuth2 Access Token")) {
return System.getProperties().getProperty("google.accesstoken");
}
if (user.equals("Google Cloud Storage (api-project-408246103372) OAuth2 Refresh Token")) {
return System.getProperties().getProperty("google.refreshtoken");
}
return null;
}
}, new DisabledProgressListener());
login.check(session, new DisabledCancelCallback());
}
use of ch.cyberduck.core.LoginConnectionService in project cyberduck by iterate-ch.
the class AbstractGoogleStorageTest method setup.
@Before
public void setup() throws Exception {
final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new GoogleStorageProtocol())));
final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Google Cloud Storage.cyberduckprofile"));
final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials(System.getProperties().getProperty("google.projectid"), null));
session = new GoogleStorageSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
fail(reason);
return null;
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore() {
@Override
public String getPassword(final Scheme scheme, final int port, final String hostname, final String user) {
if (user.equals("Google Cloud Storage (api-project-408246103372) OAuth2 Access Token")) {
return System.getProperties().getProperty("google.accesstoken");
}
if (user.equals("Google Cloud Storage (api-project-408246103372) OAuth2 Refresh Token")) {
return System.getProperties().getProperty("google.refreshtoken");
}
return null;
}
}, new DisabledProgressListener());
login.check(session, new DisabledCancelCallback());
}
use of ch.cyberduck.core.LoginConnectionService in project cyberduck by iterate-ch.
the class AbstractSwiftTest method setup.
@Before
public void setup() throws Exception {
session = new SwiftSession(new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com", new Credentials(System.getProperties().getProperty("rackspace.key"), System.getProperties().getProperty("rackspace.secret"))), new DisabledX509TrustManager(), new DefaultX509KeyManager());
final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
fail(reason);
return null;
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
login.check(session, new DisabledCancelCallback());
}
use of ch.cyberduck.core.LoginConnectionService in project cyberduck by iterate-ch.
the class OneDriveBusinessContextLoginTest method testLogin.
@Test(expected = LoginCanceledException.class)
public void testLogin() throws Exception {
final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new OneDriveProtocol())));
final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Microsoft SharePoint.cyberduckprofile"));
final Host host = new Host(profile, profile.getDefaultHostname());
final OneDriveSession session = new OneDriveSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager());
new LoginConnectionService(new DisabledLoginCallback() {
@Override
public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
assertEquals("OAuth2 Authentication", title);
throw new LoginCanceledException();
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore() {
@Override
public String getPassword(Scheme scheme, int port, String hostname, String user) {
if ("Microsoft OneDrive Business OAuth2 Access Token".equals(user)) {
return System.getProperties().getProperty("onedrive.business.accesstoken");
}
if ("Microsoft OneDrive Business OAuth2 Refresh Token".equals(user)) {
return System.getProperties().getProperty("onedrive.business.refreshtoken");
}
return null;
}
@Override
public String getPassword(String hostname, String user) {
return super.getPassword(hostname, user);
}
}, new DisabledProgressListener()).connect(session, new DisabledCancelCallback());
assertEquals("/b!9prv2DvXt0Cua27a0kKBHlYP69u02QdCtkueQRimv8UsYPDHr-_uQoMvBiuYAjdH", (new OneDriveHomeFinderService().find().getAbsolute()));
}
use of ch.cyberduck.core.LoginConnectionService in project cyberduck by iterate-ch.
the class SpectraBulkServiceTest method testPreUploadDirectoryFile.
@Test
public void testPreUploadDirectoryFile() 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());
final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {
@Override
public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
//
}
}, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
service.connect(session, new DisabledCancelCallback());
final Map<TransferItem, TransferStatus> files = new HashMap<>();
final Path directory = new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory));
final TransferStatus directoryStatus = new TransferStatus().withLength(0L);
files.put(new TransferItem(directory), directoryStatus);
final TransferStatus fileStatus = new TransferStatus().withLength(1L);
files.put(new TransferItem(new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file))), fileStatus);
final SpectraBulkService bulk = new SpectraBulkService(session);
final Set<UUID> set = bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
assertEquals(1, set.size());
assertEquals(1, bulk.query(Transfer.Type.upload, directory, directoryStatus).size());
assertEquals(1, bulk.query(Transfer.Type.upload, directory, fileStatus).size());
for (TransferItem item : files.keySet()) {
new SpectraDeleteFeature(session).delete(Collections.singletonList(item.remote), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
session.close();
}
Aggregations