use of org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldUpdateTCPConnectionSettingsWithValidConnectionAvailable.
@Test
public void shouldUpdateTCPConnectionSettingsWithValidConnectionAvailable() {
// given
configureTCPConnection();
openConnectionEditionWizard("Test");
// when: switch to TCP connection settings and save
bot.text(0).setText("foo");
bot.radio(0).click();
bot.text(1).setText("/var/run/docker.sock");
getFinishButton().click();
// then
final IDockerConnection fooConnection = DockerConnectionManager.getInstance().findConnection("foo");
assertThat(fooConnection).isNotNull();
assertThat(fooConnection.getName()).isEqualTo("foo");
assertThat(fooConnection.getSettings()).isInstanceOf(UnixSocketConnectionSettings.class);
final UnixSocketConnectionSettings connectionSettings = (UnixSocketConnectionSettings) fooConnection.getSettings();
assertThat(connectionSettings.getPath()).isEqualTo("unix:///var/run/docker.sock");
}
use of org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenUnixConnectionSettingsChanged.
@Test
public void shouldResetConnectionStateWhenUnixConnectionSettingsChanged() throws IOException {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureUnixSocketConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
final File tmpDockerSocketFile = folder.newFile("docker.sock");
assertThat(connection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
// when
openConnectionEditionWizard("Test");
bot.text(1).setText(tmpDockerSocketFile.getAbsolutePath());
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new UnixSocketConnectionSettings(tmpDockerSocketFile.getAbsolutePath()));
assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
use of org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged() throws IOException {
// given
final IDockerConnection connection = configureUnixSocketConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
final File tmpDockerSocketFile = folder.newFile("docker.sock");
// 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(1).setText(tmpDockerSocketFile.getAbsolutePath());
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new UnixSocketConnectionSettings(tmpDockerSocketFile.getAbsolutePath()));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings 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.UnixSocketConnectionSettings in project linuxtools by eclipse.
the class MockDockerConnectionSettingsFinder method validUnixSocketConnectionAvailable.
/**
* Configures the {@link DockerConnectionManager} singleton to being able to
* detect a <strong>valid Unix Socket</strong> to a Docker daemon.
*/
public static void validUnixSocketConnectionAvailable(final String connectionName, final String unixSocketPath) {
final IDockerConnectionSettingsFinder validUnixSocketConnectionAvailable = Mockito.mock(IDockerConnectionSettingsFinder.class);
final UnixSocketConnectionSettings unixSocketConnectionSettings = new UnixSocketConnectionSettings(unixSocketPath);
// unixSocketConnectionSettings.setName("mock");
unixSocketConnectionSettings.setSettingsResolved(true);
Mockito.when(validUnixSocketConnectionAvailable.findDefaultConnectionSettings()).thenReturn(unixSocketConnectionSettings);
Mockito.when(validUnixSocketConnectionAvailable.resolveConnectionName(Matchers.any(IDockerConnectionSettings.class))).thenReturn(connectionName);
DockerConnectionManager.getInstance().setConnectionSettingsFinder(validUnixSocketConnectionAvailable);
}
Aggregations