use of org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenTCPConnectionSettingsChanged.
@Test
public void shouldResetConnectionStateWhenTCPConnectionSettingsChanged() {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// when
openConnectionEditionWizard("Test");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
use of org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenTCPConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenTCPConnectionSettingsChanged() {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// let's ignore the connection savings that may have occurred when
// adding elements from the extension points
Mockito.reset(connectionStorageManager);
// when
openConnectionEditionWizard("Test");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldUpdateUnixSocketConnectionSettingsWithValidConnectionAvailable.
@Test
public void shouldUpdateUnixSocketConnectionSettingsWithValidConnectionAvailable() {
// given
configureTCPConnection();
openConnectionEditionWizard("Test");
// when: switch to TCP connection settings and save
bot.text(0).setText("foo");
bot.radio(1).click();
bot.text(2).setText("http://foo:1234");
bot.checkBox(0).select();
bot.text(3).setText(PATH_TO_CERTS);
getFinishButton().click();
// then
final IDockerConnection fooConnection = DockerConnectionManager.getInstance().findConnection("foo");
assertThat(fooConnection).isNotNull();
assertThat(fooConnection.getName()).isEqualTo("foo");
assertThat(fooConnection.getSettings()).isInstanceOf(TCPConnectionSettings.class);
final TCPConnectionSettings connectionSettings = (TCPConnectionSettings) fooConnection.getSettings();
assertThat(connectionSettings.getHost()).isEqualTo("https://foo:1234");
assertThat(connectionSettings.isTlsVerify()).isEqualTo(true);
assertThat(connectionSettings.getPathToCertificates()).isEqualTo(PATH_TO_CERTS);
}
use of org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings in project linuxtools by eclipse.
the class DockerConnectionManagerTest method testExtensionPointProvidedConnections.
@Test
public void testExtensionPointProvidedConnections() {
DefaultDockerConnectionSettingsFinder finder = new DefaultDockerConnectionSettingsFinder();
List<IDockerConnectionSettings> settings = finder.getKnownConnectionSettings();
assertTrue(settings.size() > 0);
for (IDockerConnectionSettings s : settings) {
if (s instanceof TCPConnectionSettings) {
TCPConnectionSettings t = (TCPConnectionSettings) s;
assertThat(t.getType()).isEqualTo(BindingType.TCP_CONNECTION);
assertThat(t.getHost()).isEqualTo("https://1.2.3.4:5678");
assertThat(t.getPathToCertificates()).isEqualTo("/foo/bar/baz/certs");
assertThat(t.getName()).isEqualTo("https://1.2.3.4:5678");
} else if (s instanceof UnixSocketConnectionSettings) {
UnixSocketConnectionSettings t = (UnixSocketConnectionSettings) s;
// skip if this is the Linux native or Docker for Mac daemon
if (t.getPath().equals("unix:///var/run/docker.sock")) {
continue;
}
assertThat(t.getType()).isEqualTo(BindingType.UNIX_SOCKET_CONNECTION);
assertThat(t.getPath()).isEqualTo("unix:///foo/bar/baz/docker.sock");
assertThat(t.getName()).isEqualTo("unix:///foo/bar/baz/docker.sock");
} else {
fail("Docker Connection Settings does not match a known type");
}
}
}
use of org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings in project linuxtools by eclipse.
the class MockDockerConnectionSettingsFinder method validTCPConnectionAvailable.
public static void validTCPConnectionAvailable(final String connectionName, final String host, final String pathToCerts) {
final IDockerConnectionSettingsFinder validTCPSocketConnectionAvailable = Mockito.mock(IDockerConnectionSettingsFinder.class);
final TCPConnectionSettings tcpConnectionSettings = new TCPConnectionSettings(host, pathToCerts);
// tcpConnectionSettings.setName("mock");
tcpConnectionSettings.setSettingsResolved(true);
Mockito.when(validTCPSocketConnectionAvailable.findDefaultConnectionSettings()).thenReturn(tcpConnectionSettings);
Mockito.when(validTCPSocketConnectionAvailable.resolveConnectionName(Matchers.any(IDockerConnectionSettings.class))).thenReturn(connectionName);
DockerConnectionManager.getInstance().setConnectionSettingsFinder(validTCPSocketConnectionAvailable);
}
Aggregations