Skip to content

Commit

Permalink
Update BrowserWebDriverContainer to honor existing no_proxy setting
Browse files Browse the repository at this point in the history
  • Loading branch information
roamingthings committed Oct 21, 2018
1 parent 3ee82e9 commit 4ed091b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ protected void configure() {

addExposedPorts(SELENIUM_PORT, VNC_PORT);
addEnv("TZ", timeZone);
addEnv("no_proxy", "localhost");

if (!getEnvMap().containsKey("no_proxy")) {
addEnv("no_proxy", "localhost");
}

setCommand("/opt/bin/entry_point.sh");

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.testcontainers.junit;

import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testcontainers.containers.BrowserWebDriverContainer;

import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;

public class BrowserWebDriverContainerTest {

private static final String NO_PROXY_VALUE = "localhost,.noproxy-domain.com";

@Rule
public BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer()
.withDesiredCapabilities(DesiredCapabilities.chrome())
.withEnv("no_proxy", NO_PROXY_VALUE);

@Rule
public BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer()
.withDesiredCapabilities(DesiredCapabilities.chrome());

@Test
public void honorPresetNoProxyEnvironment() {
Object no_proxy = chromeWithNoProxySet.getEnvMap().get("no_proxy");
assertEquals("no_proxy should be preserved by the container rule", NO_PROXY_VALUE, no_proxy);
}

@Test
public void provideDefaultNoProxyEnvironmentIfNotSet() {
Object no_proxy = chromeWithoutNoProxySet.getEnvMap().get("no_proxy");
assertEquals("no_proxy should be set to default if not already present", "localhost", no_proxy);
}
}

0 comments on commit 4ed091b

Please sign in to comment.