use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionTest method should_not_equals_if_different_scheme.
@Test
public void should_not_equals_if_different_scheme() throws Exception {
// given
Connection two = new Connection("http://localhost:8443", null, null);
// when
// then
assertThat(connection).isNotEqualTo(two);
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorsTest method testBasicAuthenticationValidatorInUI.
@Test
public void testBasicAuthenticationValidatorInUI() {
Connection connection1 = mockConnection(HOST1, USER1, null);
mockConnection(HOST2, USER2, null);
ConnectionWizardPageModel pageModel = mockConnectionWizardPageModel(connection1);
Mockito.when(pageModel.getHost()).thenReturn(HOST2);
IValueChangeListener<Object> l = new IValueChangeListener<Object>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends Object> event) {
}
};
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Composite composite = new Composite(shell, SWT.NONE);
try {
BasicAuthenticationDetailView view = new BasicAuthenticationDetailView(pageModel, l, null);
DataBindingContext dbc = new DataBindingContext();
view.createControls(shell, null, dbc);
view.onVisible(null, dbc);
view.getPasswordTextControl().setText("pass");
view.getUsernameTextControl().setText(USER2);
MultiValidator v = findValidator(dbc);
Assert.assertEquals(IStatus.ERROR, getStatusSeverity(v));
view.getUsernameTextControl().setText(USER3);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
} finally {
composite.dispose();
}
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorsTest method testBasicAuthenticationValidator.
@Test
public void testBasicAuthenticationValidator() {
Connection connection1 = mockConnection(HOST1, USER1, null);
mockConnection(HOST2, USER2, null);
ConnectionWizardPageModel pageModel = mockConnectionWizardPageModel(connection1);
WritableValue<String> usernameObservable = new WritableValue<String>();
WritableValue<String> urlObservable = new WritableValue<String>();
MultiValidator v = ConnectionValidatorFactory.createBasicAuthenticationValidator(pageModel, usernameObservable, urlObservable);
v.observeValidatedValue(urlObservable);
// New connection
urlObservable.setValue(HOST3);
usernameObservable.setValue(USER3);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
urlObservable.setValue(HOST2);
// Host exists, but token is different
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
usernameObservable.setValue(USER2);
// Existing not selected connection
Assert.assertEquals(IStatus.ERROR, getStatusSeverity(v));
// Selected connection
urlObservable.setValue(HOST1);
usernameObservable.setValue(USER1);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class OpenshiftJMXConnectionProvider method createConnection.
@Override
protected IConnectionWrapper createConnection(IServer server) {
IConnection openshiftCon = OpenShiftServerUtils.getConnection(server);
String url = computeJolokiaURL(server);
if (url != null) {
JolokiaConnectionWrapper cw = new JolokiaConnectionWrapper() {
@Override
public IConnectionProvider getProvider() {
return ExtensionManager.getProvider(PROVIDER_ID);
}
};
cw.setId(server.getName());
cw.setUrl(url);
cw.setType("POST");
cw.setIgnoreSSLErrors(true);
Map<String, String> headers = new HashMap<>();
headers.put(AUTHORIZATION_HEADER_KEY, AUTHORIZATION_HEADER_VALUE_PREFIX + ((Connection) openshiftCon).getToken());
cw.setHeaders(headers);
return cw;
} else {
return null;
}
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class OpenShiftLaunchController method waitForDeploymentConfigReady.
protected boolean waitForDeploymentConfigReady(IServer server, IProgressMonitor monitor) throws CoreException {
monitor.subTask("Waiting for deployment configs to become available...");
Connection connection = OpenShiftServerUtils.getConnectionChecked(server);
IResource resource = OpenShiftServerUtils.getResourceChecked(server, connection, monitor);
long timeout = System.currentTimeMillis() + WAIT_FOR_DEPLOYMENTCONFIG_TIMEOUT;
while ((ResourceUtils.getDeploymentConfigFor(resource, connection)) == null) {
if (!sleep(RECHECK_DELAY, timeout, monitor)) {
return false;
}
}
return true;
}
Aggregations