From 66fe43597270647c66fe0da7b5b995f2af465c3b Mon Sep 17 00:00:00 2001 From: Gyanesha Date: Wed, 26 Feb 2020 14:11:51 +0530 Subject: [PATCH 01/10] Added no proxy hosts when using proxy in CliGitAPIImpl --- .../java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 47202442b0..788951e395 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -2013,6 +2013,8 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD if ("http".equalsIgnoreCase(url.getScheme()) || "https".equalsIgnoreCase(url.getScheme())) { if (proxy != null) { + ListlistOfConfiguredNoProxyHosts = new ArrayList(); + listOfConfiguredNoProxyHosts.add("169.254.169.254"); boolean shouldProxy = true; for(Pattern p : proxy.getNoProxyHostPatterns()) { if(p.matcher(url.getHost()).matches()) { @@ -2034,6 +2036,7 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD URI http_proxy = new URI("http", userInfo, proxy.name, proxy.port, null, null, null); env.put("http_proxy", http_proxy.toString()); env.put("https_proxy", http_proxy.toString()); + env.put("NO_PROXY", String.join(", ",listOfConfiguredNoProxyHosts)); } catch (URISyntaxException ex) { throw new GitException("Failed to create http proxy uri", ex); } From dc2644a2c4416dd0a3b3ac3a3e1b9c0ebf834270 Mon Sep 17 00:00:00 2001 From: Gyanesha Date: Thu, 5 Mar 2020 16:06:58 +0530 Subject: [PATCH 02/10] Added automated test and removed the hard coded part --- .../plugins/gitclient/CliGitAPIImpl.java | 16 ++++- .../CliGitAPIImplNoProxyHostTest.java | 60 +++++++++++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 788951e395..4751c74f5f 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -1943,6 +1943,18 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD @NonNull URIish url) throws GitException, InterruptedException { return launchCommandWithCredentials(args, workDir, credentials, url, TIMEOUT); } + + /** + * Provides all the no proxy hosts from proxy object + * of ProxyConfiguration + * @return proxy hosts concatenated by commas + */ + private String getNoProxyHosts(){ + String noProxyHost = proxy.noProxyHost; + List noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); + return String.join(",",noProxyHosts); + } + private String launchCommandWithCredentials(ArgumentListBuilder args, File workDir, StandardCredentials credentials, @NonNull URIish url, @@ -2013,8 +2025,6 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD if ("http".equalsIgnoreCase(url.getScheme()) || "https".equalsIgnoreCase(url.getScheme())) { if (proxy != null) { - ListlistOfConfiguredNoProxyHosts = new ArrayList(); - listOfConfiguredNoProxyHosts.add("169.254.169.254"); boolean shouldProxy = true; for(Pattern p : proxy.getNoProxyHostPatterns()) { if(p.matcher(url.getHost()).matches()) { @@ -2036,7 +2046,7 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD URI http_proxy = new URI("http", userInfo, proxy.name, proxy.port, null, null, null); env.put("http_proxy", http_proxy.toString()); env.put("https_proxy", http_proxy.toString()); - env.put("NO_PROXY", String.join(", ",listOfConfiguredNoProxyHosts)); + env.put("no_proxy", getNoProxyHosts()); } catch (URISyntaxException ex) { throw new GitException("Failed to create http proxy uri", ex); } diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java new file mode 100644 index 0000000000..ad2020ecaf --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java @@ -0,0 +1,60 @@ +package org.jenkinsci.plugins.gitclient; + +import hudson.EnvVars; +import hudson.ProxyConfiguration; +import hudson.model.TaskListener; +import junit.framework.TestCase; +import org.junit.Test; +import org.objenesis.ObjenesisStd; + +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Test that checks all the no proxy hosts are added or not. + */ +public class CliGitAPIImplNoProxyHostTest extends TestCase { + + private CliGitAPIImpl cliGit; + + @Test + public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, IllegalAccessException { + cliGit = new CliGitAPIImpl("git", new File("."), TaskListener.NULL, new EnvVars()); + + final String proxyHost = "172.16.1.13"; + final String proxyPort = "3128"; + final String proxyUser = null; + final String noProxyHosts = "169.254.169.254"; + + ProxyConfiguration proxyConfig = new ObjenesisStd().newInstance(ProxyConfiguration.class); + + setField(ProxyConfiguration.class, "name", proxyConfig, proxyHost); + setField(ProxyConfiguration.class, "port", proxyConfig, Integer.parseInt(proxyPort)); + setField(ProxyConfiguration.class, "userName", proxyConfig, null); + setField(ProxyConfiguration.class, "noProxyHost", proxyConfig, noProxyHosts); + setField(ProxyConfiguration.class, "password", proxyConfig, null); + setField(ProxyConfiguration.class, "secretPassword", proxyConfig, null); + + cliGit.setProxy(proxyConfig); + + try { + Method getNoProxyHosts = CliGitAPIImpl.class.getDeclaredMethod("getNoProxyHosts"); + getNoProxyHosts.setAccessible(true); + String returnValue = (String) + getNoProxyHosts.invoke(cliGit, null); + assertEquals( "NO_PROXY hosts are not set correctly" , noProxyHosts, returnValue); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + private void setField(Class clazz, String fieldName, Object object, Object value) + throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException + { + Field declaredField = clazz.getDeclaredField(fieldName); + declaredField.setAccessible(true); + declaredField.set(object, value); + } +} \ No newline at end of file From 97fa81f6f5ca4de21b13a1c1f0bcd3d1f777652b Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Fri, 26 Feb 2021 19:08:53 -0700 Subject: [PATCH 03/10] Use the proxy hosts getter rather than the field --- .../java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 617de77705..111bce4476 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -1957,7 +1957,7 @@ private String launchCommandWithCredentials(ArgumentListBuilder args, File workD * @return proxy hosts concatenated by commas */ private String getNoProxyHosts(){ - String noProxyHost = proxy.noProxyHost; + String noProxyHost = proxy.getNoProxyHost(); List noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); return String.join(",",noProxyHosts); } From 6bc44b9b1197e3e600d9dc2ace575f4e65181ab1 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Tue, 11 Apr 2023 12:10:40 -0600 Subject: [PATCH 04/10] Format source changes --- .../plugins/gitclient/CliGitAPIImpl.java | 17 ++++++++++------- .../gitclient/CliGitAPIImplNoProxyHostTest.java | 17 +++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 4b84790982..3b79f24f75 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -2084,16 +2084,19 @@ private String launchCommandWithCredentials( * of ProxyConfiguration * @return proxy hosts concatenated by commas */ - private String getNoProxyHosts(){ + private String getNoProxyHosts() { String noProxyHost = proxy.getNoProxyHost(); - List noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); - return String.join(",",noProxyHosts); + List noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); + return String.join(",", noProxyHosts); } - private String launchCommandWithCredentials(ArgumentListBuilder args, File workDir, - StandardCredentials credentials, - @NonNull URIish url, - Integer timeout) throws GitException, InterruptedException { + private String launchCommandWithCredentials( + ArgumentListBuilder args, + File workDir, + StandardCredentials credentials, + @NonNull URIish url, + Integer timeout) + throws GitException, InterruptedException { Path key = null; Path ssh = null; diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java index ad2020ecaf..976daa1023 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java @@ -3,14 +3,13 @@ import hudson.EnvVars; import hudson.ProxyConfiguration; import hudson.model.TaskListener; -import junit.framework.TestCase; -import org.junit.Test; -import org.objenesis.ObjenesisStd; - import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import junit.framework.TestCase; +import org.junit.Test; +import org.objenesis.ObjenesisStd; /** * Test that checks all the no proxy hosts are added or not. @@ -42,19 +41,17 @@ public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, I try { Method getNoProxyHosts = CliGitAPIImpl.class.getDeclaredMethod("getNoProxyHosts"); getNoProxyHosts.setAccessible(true); - String returnValue = (String) - getNoProxyHosts.invoke(cliGit, null); - assertEquals( "NO_PROXY hosts are not set correctly" , noProxyHosts, returnValue); + String returnValue = (String) getNoProxyHosts.invoke(cliGit, null); + assertEquals("NO_PROXY hosts are not set correctly", noProxyHosts, returnValue); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } } private void setField(Class clazz, String fieldName, Object object, Object value) - throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException - { + throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Field declaredField = clazz.getDeclaredField(fieldName); declaredField.setAccessible(true); declaredField.set(object, value); } -} \ No newline at end of file +} From 288cfe57cb0c4f7196923b18baf9888485832239 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Tue, 11 Apr 2023 13:08:41 -0600 Subject: [PATCH 05/10] Replace Guava reference with pure Java --- .../java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 3b79f24f75..6902968c19 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -2086,7 +2086,7 @@ private String launchCommandWithCredentials( */ private String getNoProxyHosts() { String noProxyHost = proxy.getNoProxyHost(); - List noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); + List noProxyHosts = new ArrayList<>(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); return String.join(",", noProxyHosts); } From ef709b06e8087dbd2b0587a9f3e445a6ef11ca3e Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Wed, 13 Sep 2023 05:25:08 -0600 Subject: [PATCH 06/10] Initialize proxy in CliGitAPIImpl constructor Silence a spotbugs warning. --- src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index 921b5492b7..ad3737f8ef 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -332,6 +332,7 @@ protected CliGitAPIImpl(String gitExe, File workspace, TaskListener listener, En this.listener = listener; this.gitExe = gitExe; this.environment = environment; + this.proxy = null; if (isZos() && System.getProperty("ibm.system.encoding") != null) { this.encoding = From 91a64cc33e3178234efac95f82d1880e59053621 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Wed, 13 Sep 2023 05:25:51 -0600 Subject: [PATCH 07/10] Make getNoProxyHosts package protected for testing --- .../jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 4 ++-- .../gitclient/CliGitAPIImplNoProxyHostTest.java | 12 +----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index ad3737f8ef..e35b98279d 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -2082,10 +2082,10 @@ private String launchCommandWithCredentials( /** * Provides all the no proxy hosts from proxy object - * of ProxyConfiguration + * of ProxyConfiguration. Package protected for testing. * @return proxy hosts concatenated by commas */ - private String getNoProxyHosts() { + String getNoProxyHosts() { String noProxyHost = proxy.getNoProxyHost(); List noProxyHosts = new ArrayList<>(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); return String.join(",", noProxyHosts); diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java index 976daa1023..3ccd1c97df 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java @@ -5,8 +5,6 @@ import hudson.model.TaskListener; import java.io.File; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import junit.framework.TestCase; import org.junit.Test; import org.objenesis.ObjenesisStd; @@ -37,15 +35,7 @@ public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, I setField(ProxyConfiguration.class, "secretPassword", proxyConfig, null); cliGit.setProxy(proxyConfig); - - try { - Method getNoProxyHosts = CliGitAPIImpl.class.getDeclaredMethod("getNoProxyHosts"); - getNoProxyHosts.setAccessible(true); - String returnValue = (String) getNoProxyHosts.invoke(cliGit, null); - assertEquals("NO_PROXY hosts are not set correctly", noProxyHosts, returnValue); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } + assertEquals("NO_PROXY hosts are not set correctly", noProxyHosts, cliGit.getNoProxyHosts()); } private void setField(Class clazz, String fieldName, Object object, Object value) From 10ebd1f3c453ff8022628a8b7a9d4392b0f92050 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Wed, 13 Sep 2023 05:50:19 -0600 Subject: [PATCH 08/10] Guard against null pointer exceptions --- .../org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java index e35b98279d..daf1d10b5c 100644 --- a/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java +++ b/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java @@ -2083,10 +2083,17 @@ private String launchCommandWithCredentials( /** * Provides all the no proxy hosts from proxy object * of ProxyConfiguration. Package protected for testing. - * @return proxy hosts concatenated by commas + * @return hosts not intended to be proxied, concatenated by commas */ + @NonNull String getNoProxyHosts() { + if (proxy == null) { + return ""; + } String noProxyHost = proxy.getNoProxyHost(); + if (noProxyHost == null || noProxyHost.isEmpty()) { + return ""; + } List noProxyHosts = new ArrayList<>(Arrays.asList(noProxyHost.split("[\t\n,|]+"))); return String.join(",", noProxyHosts); } From ee7c2fd7ba4e2096567106ad6134102b8c92fd4c Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Wed, 13 Sep 2023 05:50:38 -0600 Subject: [PATCH 09/10] Use constructor to simplify test --- .../CliGitAPIImplNoProxyHostTest.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java index 3ccd1c97df..01a815cee7 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java @@ -4,10 +4,8 @@ import hudson.ProxyConfiguration; import hudson.model.TaskListener; import java.io.File; -import java.lang.reflect.Field; import junit.framework.TestCase; import org.junit.Test; -import org.objenesis.ObjenesisStd; /** * Test that checks all the no proxy hosts are added or not. @@ -21,27 +19,14 @@ public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, I cliGit = new CliGitAPIImpl("git", new File("."), TaskListener.NULL, new EnvVars()); final String proxyHost = "172.16.1.13"; - final String proxyPort = "3128"; + final int proxyPort = 3128; final String proxyUser = null; + final String proxyPassword = null; final String noProxyHosts = "169.254.169.254"; - ProxyConfiguration proxyConfig = new ObjenesisStd().newInstance(ProxyConfiguration.class); - - setField(ProxyConfiguration.class, "name", proxyConfig, proxyHost); - setField(ProxyConfiguration.class, "port", proxyConfig, Integer.parseInt(proxyPort)); - setField(ProxyConfiguration.class, "userName", proxyConfig, null); - setField(ProxyConfiguration.class, "noProxyHost", proxyConfig, noProxyHosts); - setField(ProxyConfiguration.class, "password", proxyConfig, null); - setField(ProxyConfiguration.class, "secretPassword", proxyConfig, null); - + ProxyConfiguration proxyConfig = + new ProxyConfiguration(proxyHost, proxyPort, proxyUser, proxyPassword, noProxyHosts); cliGit.setProxy(proxyConfig); assertEquals("NO_PROXY hosts are not set correctly", noProxyHosts, cliGit.getNoProxyHosts()); } - - private void setField(Class clazz, String fieldName, Object object, Object value) - throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - Field declaredField = clazz.getDeclaredField(fieldName); - declaredField.setAccessible(true); - declaredField.set(object, value); - } } From 37847ce6e1879822a6360398c9e5967918fcbd7d Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Wed, 13 Sep 2023 06:00:19 -0600 Subject: [PATCH 10/10] Test with JUnit 4, not JUnit 3 --- .../CliGitAPIImplNoProxyHostTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java index 01a815cee7..1d62d7112f 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplNoProxyHostTest.java @@ -1,22 +1,29 @@ package org.jenkinsci.plugins.gitclient; +import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.Matchers.*; + import hudson.EnvVars; import hudson.ProxyConfiguration; import hudson.model.TaskListener; import java.io.File; -import junit.framework.TestCase; +import org.junit.Before; import org.junit.Test; /** * Test that checks all the no proxy hosts are added or not. */ -public class CliGitAPIImplNoProxyHostTest extends TestCase { +public class CliGitAPIImplNoProxyHostTest { private CliGitAPIImpl cliGit; + @Before + public void createCliGit() { + cliGit = new CliGitAPIImpl("git", new File("."), TaskListener.NULL, new EnvVars()); + } + @Test public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, IllegalAccessException { - cliGit = new CliGitAPIImpl("git", new File("."), TaskListener.NULL, new EnvVars()); final String proxyHost = "172.16.1.13"; final int proxyPort = 3128; @@ -27,6 +34,11 @@ public void test_no_proxy_host_is_set_correctly() throws NoSuchFieldException, I ProxyConfiguration proxyConfig = new ProxyConfiguration(proxyHost, proxyPort, proxyUser, proxyPassword, noProxyHosts); cliGit.setProxy(proxyConfig); - assertEquals("NO_PROXY hosts are not set correctly", noProxyHosts, cliGit.getNoProxyHosts()); + assertThat(cliGit.getNoProxyHosts(), is(noProxyHosts)); + } + + @Test + public void test_default_value() { + assertThat(cliGit.getNoProxyHosts(), is("")); } }