Search in sources :

Example 1 with TCPConnectionSettings

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);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Example 2 with TCPConnectionSettings

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());
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Example 3 with TCPConnectionSettings

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);
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Example 4 with TCPConnectionSettings

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");
        }
    }
}
Also used : DefaultDockerConnectionSettingsFinder(org.eclipse.linuxtools.internal.docker.core.DefaultDockerConnectionSettingsFinder) UnixSocketConnectionSettings(org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Example 5 with TCPConnectionSettings

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);
}
Also used : IDockerConnectionSettingsFinder(org.eclipse.linuxtools.docker.core.IDockerConnectionSettingsFinder) IDockerConnectionSettings(org.eclipse.linuxtools.docker.core.IDockerConnectionSettings) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)

Aggregations

TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)9 Test (org.junit.Test)5 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)4 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)3 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)3 IDockerConnectionSettings (org.eclipse.linuxtools.docker.core.IDockerConnectionSettings)2 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 ILaunchManager (org.eclipse.debug.core.ILaunchManager)1 ExecutionArguments (org.eclipse.jdt.launching.ExecutionArguments)1 IVMInstall (org.eclipse.jdt.launching.IVMInstall)1 VMRunnerConfiguration (org.eclipse.jdt.launching.VMRunnerConfiguration)1