use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftRegistryDefault.
@Test
public void testOpenshiftRegistryDefault() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift36");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s, "10.1.2.2", "2376", null);
ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
IConnection con = util.createOpenshiftConnection(adb, registry);
assertNotNull(con);
Object o = ((Connection) con).getExtendedProperties().get(ICommonAttributes.IMAGE_REGISTRY_URL_KEY);
assertEquals("https://hub.openshift.rhel-cdk.10.1.2.2.xip.io", o);
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftConnectionCredentials.
@Test
public void testOpenshiftConnectionCredentials() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift33");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s);
IConnection con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "openshift-dev");
assertEquals(con.getPassword(), "devel");
createCDKFile("Basic", "test", null);
adb = createLoader(s);
con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "test");
assertEquals(con.getPassword(), null);
createCDKFile("Basic", "test", "pass");
adb = createLoader(s);
con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "test");
assertEquals(con.getPassword(), "pass");
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftRegistry.
@Test
public void testOpenshiftRegistry() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift35");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s, "10.1.2.2", "2376", "https://custom.url");
ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
IConnection con = util.createOpenshiftConnection(adb, registry);
assertNotNull(con);
Object o = ((Connection) con).getExtendedProperties().get(ICommonAttributes.IMAGE_REGISTRY_URL_KEY);
assertEquals(o, "https://custom.url");
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtility method createOpenshiftConnection.
public IConnection createOpenshiftConnection(ServiceManagerEnvironment env, ConnectionsRegistry registry) {
// Create the connection
String soughtHost = env.openshiftHost + ":" + env.openshiftPort;
ConnectionsFactoryTracker connectionsFactory = new ConnectionsFactoryTracker();
connectionsFactory.open();
IConnectionFactory factory = connectionsFactory.getById(IConnectionsFactory.CONNECTIONFACTORY_OPENSHIFT_ID);
IConnection con = factory.create(soughtHost);
// Set some defaults
String authScheme = env.getAuthorizationScheme();
String username = env.getUsername();
String password = env.getPassword();
if (authScheme != null && !authScheme.isEmpty()) {
authScheme = new String("" + authScheme.charAt(0)).toUpperCase() + authScheme.substring(1);
}
((Connection) con).setAuthScheme(authScheme);
((Connection) con).setUsername(username);
if (password != null) {
((Connection) con).setPassword(password);
}
((Connection) con).setRememberPassword(true);
String ocLoc = env.get(ServiceManagerEnvironmentLoader.OC_LOCATION_KEY);
if (ocLoc != null) {
((Connection) con).setExtendedProperty(ICommonAttributes.OC_LOCATION_KEY, ocLoc);
((Connection) con).setExtendedProperty(ICommonAttributes.OC_OVERRIDE_KEY, true);
}
updateOpenshiftConnection(env, con, false);
if (registry != null)
registry.add(con);
return con;
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ConfigureDependentFrameworksListener method configureOpenshift.
private void configureOpenshift(IServer server, ServiceManagerEnvironment adb) {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IConnection con = util.findExistingOpenshiftConnection(server, adb);
if (con == null) {
con = util.createOpenshiftConnection(adb);
} else {
util.updateOpenshiftConnection(adb, con);
}
if (con != null) {
con.connect();
}
}
Aggregations