Search in sources :

Example 6 with ClientBuilder

use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.

the class ConnectionFactory method create.

@Override
public Connection create(String url) {
    if (StringUtils.isEmpty(url)) {
        return null;
    }
    try {
        LazySSLCertificateCallback sslCertCallback = new LazySSLCertificateCallback();
        IClient client = new ClientBuilder(url).sslCertificateCallback(sslCertCallback).withMaxRequests(ConnectionProperties.MAX_REQUESTS).withMaxRequestsPerHost(ConnectionProperties.MAX_REQUESTS).build();
        return new Connection(client, new LazyCredentialsPrompter());
    } catch (OpenShiftException e) {
        OpenShiftCoreActivator.pluginLog().logInfo(NLS.bind("Could not create OpenShift connection: Malformed url {0}", url), e);
        return null;
    }
}
Also used : LazySSLCertificateCallback(org.jboss.tools.openshift.core.LazySSLCertificateCallback) OpenShiftException(com.openshift.restclient.OpenShiftException) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IClient(com.openshift.restclient.IClient) LazyCredentialsPrompter(org.jboss.tools.openshift.core.LazyCredentialsPrompter) ClientBuilder(com.openshift.restclient.ClientBuilder)

Example 7 with ClientBuilder

use of com.openshift.restclient.ClientBuilder in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_not_credentialsEqual_if_different_token.

@Test
public void should_not_credentialsEqual_if_different_token() throws Exception {
    // given
    connection = new Connection(new ClientBuilder("https://someplace").withUserName("foo").withPassword("bar").usingToken("mytoken").build(), null);
    Connection two = (Connection) connection.clone();
    assertThat(two).isEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isTrue();
    // when
    two.setToken("tokenTwo");
    // then
    assertThat(two).isEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isFalse();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) ClientBuilder(com.openshift.restclient.ClientBuilder) Test(org.junit.Test)

Aggregations

ClientBuilder (com.openshift.restclient.ClientBuilder)7 IClient (com.openshift.restclient.IClient)3 OpenShiftException (com.openshift.restclient.OpenShiftException)3 IOException (java.io.IOException)3 LazySSLCertificateCallback (org.jboss.tools.openshift.core.LazySSLCertificateCallback)3 ISSLCertificateCallback (com.openshift.restclient.ISSLCertificateCallback)2 TimeoutException (java.util.concurrent.TimeoutException)2 CommandTimeoutException (org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException)2 Connection (org.jboss.tools.openshift.core.connection.Connection)2 Test (org.junit.Test)2 IResourceFactory (com.openshift.restclient.IResourceFactory)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 CoreException (org.eclipse.core.runtime.CoreException)1 RedDeerException (org.eclipse.reddeer.common.exception.RedDeerException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1