Search in sources :

Example 71 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_add_extendedProperty.

@Test
public void should_add_extendedProperty() throws Exception {
    // given
    Connection connection = new Connection("http://localhost", null, null);
    assertThat(connection.getExtendedProperties()).isEmpty();
    // when
    connection.setExtendedProperty("foo", "bar");
    // then
    assertThat(connection.getExtendedProperties()).hasSize(1);
    assertThat(connection.getExtendedProperties()).containsEntry("foo", "bar");
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 72 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_update_connection_by_connection.

@Test
public void should_update_connection_by_connection() throws Exception {
    // pre-conditions
    Connection connection = new Connection("http://localhost:8443", null, null);
    connection.setUsername("foo");
    connection.setPassword("bar");
    connection.setToken("000000000000111111111");
    connection.setRememberPassword(true);
    connection.setRememberToken(false);
    String newUsername = "shadowman";
    String newHost = "http://www.redhat.com";
    String newPassword = "1q2w3e";
    String newToken = "1234567890abcdefghijklmz";
    boolean newRememberPassword = false;
    boolean newRememberToken = true;
    Connection updatingConnection = new Connection(newHost, null, null);
    updatingConnection.setUsername(newUsername);
    updatingConnection.setPassword(newPassword);
    updatingConnection.setRememberPassword(newRememberPassword);
    updatingConnection.setToken(newToken);
    updatingConnection.setRememberToken(newRememberToken);
    // operations
    connection.update(updatingConnection);
    // verifications
    assertThat(connection.getHost()).isEqualTo(newHost);
    assertThat(connection.getUsername()).isEqualTo(newUsername);
    assertThat(connection.getPassword()).isEqualTo(newPassword);
    assertThat(connection.getToken()).isEqualTo(newToken);
    assertThat(connection.isRememberPassword()).isEqualTo(newRememberPassword);
    assertThat(connection.isRememberToken()).isEqualTo(newRememberToken);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 73 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_not_equals_if_different_host.

@Test
public void should_not_equals_if_different_host() throws Exception {
    // given
    Connection two = new Connection("https://openshift.redhat.com:8443", null, null);
    two.setUsername("foo");
    // when
    // then
    assertThat(connection).isNotEqualTo(two);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 74 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class LazyCredentialsPrompterTest method setup.

@Before
public void setup() throws MalformedURLException {
    when(client.getBaseURL()).thenReturn(new URL("https://localhost:8443"));
    this.lazyPrompter = spy(new LazyCredentialsPrompter());
    this.connection = new Connection(client.getBaseURL().toString(), lazyPrompter, null);
    when(permissiveExtensionPrompter.promptAndAuthenticate(connection, null)).thenReturn(true);
    when(denyingExtensionPrompter.promptAndAuthenticate(connection, null)).thenReturn(true);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) LazyCredentialsPrompter(org.jboss.tools.openshift.core.LazyCredentialsPrompter) URL(java.net.URL) Before(org.junit.Before)

Example 75 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionPersistencyTest method setup.

@Before
public void setup() throws Exception {
    this.connection1 = new Connection("https://localhost:8442", null, null);
    connection1.setUsername("foo");
    connection1.setToken("bar");
    this.connection2 = new Connection("https://localhost:8443", null, null);
    connection2.setUsername("bar");
    connection2.setToken("foo");
    persistency = new TestConnectionPersistency();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Before(org.junit.Before)

Aggregations

Connection (org.jboss.tools.openshift.core.connection.Connection)110 Test (org.junit.Test)48 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)30 IResource (com.openshift.restclient.model.IResource)27 IProject (com.openshift.restclient.model.IProject)18 IService (com.openshift.restclient.model.IService)11 IStatus (org.eclipse.core.runtime.IStatus)11 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)9 Collection (java.util.Collection)8 List (java.util.List)8 ISelection (org.eclipse.jface.viewers.ISelection)8 IPod (com.openshift.restclient.model.IPod)7 ArrayList (java.util.ArrayList)7 CoreException (org.eclipse.core.runtime.CoreException)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IRoute (com.openshift.restclient.model.route.IRoute)6 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Status (org.eclipse.core.runtime.Status)6