Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-61193] Export no_proxy hosts when using HTTP proxy #516

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test with JUnit 4, not JUnit 3
  • Loading branch information
MarkEWaite committed Sep 13, 2023
commit 37847ce6e1879822a6360398c9e5967918fcbd7d
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(""));
}
}