Search in sources :

Example 36 with Connection

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

the class ConnectionTest method clone_should_create_identical_connection.

@Test
public void clone_should_create_identical_connection() throws Exception {
    // pre-conditions
    Connection connection = new Connection("https://localhost:8443", null, null);
    connection.setUsername("shadowman");
    connection.setPassword("foo");
    connection.setRememberPassword(false);
    connection.setToken("1234567890abcdefghijklmnopqrstuvz%$");
    connection.setRememberToken(true);
    // operations
    Connection clonedConnection = (Connection) connection.clone();
    // verifications
    assertThat(clonedConnection.getUsername()).isEqualTo(clonedConnection.getUsername());
    assertThat(clonedConnection.getPassword()).isEqualTo(clonedConnection.getPassword());
    assertThat(clonedConnection.isRememberPassword()).isEqualTo(clonedConnection.isRememberPassword());
    assertThat(clonedConnection.getToken()).isEqualTo(connection.getToken());
    assertThat(clonedConnection.isRememberToken()).isEqualTo(clonedConnection.isRememberToken());
    assertThat(clonedConnection.getHost()).isEqualTo(clonedConnection.getHost());
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 37 with Connection

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

the class ConnectionTest method should_equal_if_different_password.

@Test
public void should_equal_if_different_password() throws Exception {
    // given
    connection.setUsername("bar");
    connection.setPassword("42");
    Connection two = new Connection("https://localhost:8443", null, null);
    two.setUsername("bar");
    two.setPassword("42");
    // when
    // then
    assertThat(connection).isEqualTo(two);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 38 with Connection

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

the class ConnectionTest method should_clear_secure_data_when_connection_deleted.

@Test
public void should_clear_secure_data_when_connection_deleted() throws MalformedURLException {
    // pre-conditions
    Connection connection = ConnectionTestUtils.createConnection("bdshadow", "13", "https://localhost.com");
    connection.connect();
    // when
    IStoreKey key = new OpenShiftSecureStorageKey(Connection.SECURE_STORAGE_BASEKEY, connection.getHost(), connection.getUsername());
    assertTrue(SecurePreferencesFactory.getDefault().nodeExists(key.getKey()));
    connection.removeSecureStoreData();
    // then
    assertFalse(SecurePreferencesFactory.getDefault().nodeExists(key.getKey()));
}
Also used : IStoreKey(org.jboss.tools.openshift.internal.common.core.security.SecureStore.IStoreKey) OpenShiftSecureStorageKey(org.jboss.tools.openshift.internal.common.core.security.OpenShiftSecureStorageKey) Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 39 with Connection

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

the class ConnectionTest method should_equals_if_same_url_and_user.

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

Example 40 with Connection

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

the class ConnectionTest method should_not_credentials_equal_if_different_username.

@Test
public void should_not_credentials_equal_if_different_username() throws Exception {
    // given
    Connection two = (Connection) connection.clone();
    assertThat(two).isEqualTo(connection);
    // when
    two.setUsername("userTwo");
    // then
    assertThat(two).isNotEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isFalse();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

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