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());
}
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);
}
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()));
}
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);
}
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();
}
Aggregations