Skip to content

Commit

Permalink
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -41,7 +41,10 @@ static List<String> buildArguments(ProxyConfig proxyConfig, String npmRegistryUR

final String nonProxyHosts = proxy.getNonProxyHosts();
if (nonProxyHosts != null && !nonProxyHosts.isEmpty()) {
arguments.add("--noproxy=" + nonProxyHosts.replace('|',','));
final String[] nonProxyHostList = nonProxyHosts.split("\\|");
for (String nonProxyHost: nonProxyHostList) {
arguments.add("--noproxy=" + nonProxyHost.replace("*", ""));
}
}
}

Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ public class DefaultNpmRunnerTest {
private final int port = 8888;
private final String username = "someusername";
private final String password = "somepassword";
private final String nonProxyHosts = "www.google.ca|www.google.com";
private final String expectedNonProxyHosts = "www.google.ca,www.google.com";
private final String nonProxyHosts = "www.google.ca|www.google.com|*.google.de";
private final String[] expectedNonProxyHosts = new String[] {"www.google.ca","www.google.com",".google.de"};
private final String registryUrl = "www.npm.org";
private final String expectedUrl = "http://someusername:somepassword@localhost:8888";

@@ -30,9 +30,11 @@ public void buildArguments_basicTest() {

assertThat(strings, CoreMatchers.hasItem("--proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--https-proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHosts));
for (String expectedNonProxyHost: expectedNonProxyHosts) {
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHost));
}
assertThat(strings, CoreMatchers.hasItem("--registry=" + registryUrl));
assertEquals(4, strings.size());
assertEquals(6, strings.size());
}


@@ -42,8 +44,10 @@ public void buildArguments_emptyRegistryUrl() {

assertThat(strings, CoreMatchers.hasItem("--proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--https-proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHosts));
assertEquals(3, strings.size());
for (String expectedNonProxyHost: expectedNonProxyHosts) {
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHost));
}
assertEquals(5, strings.size());
}

@Test
@@ -52,8 +56,10 @@ public void buildArguments_nullRegistryUrl() {

assertThat(strings, CoreMatchers.hasItem("--proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--https-proxy=" + expectedUrl));
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHosts));
assertEquals(3, strings.size());
for (String expectedNonProxyHost: expectedNonProxyHosts) {
assertThat(strings, CoreMatchers.hasItem("--noproxy=" + expectedNonProxyHost));
}
assertEquals(5, strings.size());
}

@Test

0 comments on commit 3a1a136

Please sign in to comment.