Skip to content

Commit ac121a1

Browse files
committed
travis build fix
1 parent 15d3788 commit ac121a1

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache:
88
directories:
99
- $HOME/.gradle/caches/
1010
- $HOME/.gradle/wrapper/
11-
script: ./gradlew build --debug
11+
script: ./gradlew build --info
1212
after_success:
1313
- ./gradlew jacocoTestReport coveralls
1414

src/main/java/org/scm4j/vcs/GitVCS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
264264
protected PasswordAuthentication getPasswordAuthentication() {
265265
System.out.println(super.getRequestingSite().getHostName());
266266
System.out.println(repo.getRepoUrl());
267-
if (super.getRequestingSite().getHostName().contains(repo.getRepoUrl())) {
267+
if (super.getRequestingSite().getHostName().contains(repo.getRepoUrl()) &&
268+
super.getRequestingPort() == port) {
268269
return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray());
269270
}
270271
return super.getPasswordAuthentication();

src/test/java/org/scm4j/vcs/GitVCSTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,39 @@ public void testSetCredentials() {
9191

9292
@Test
9393
public void testProxyAuth() throws Exception {
94-
PasswordAuthentication initialAuth = Authenticator.requestPasswordAuthentication(InetAddress.getByName("127.0.0.1"),
94+
PasswordAuthentication initialAuth = Authenticator.requestPasswordAuthentication(InetAddress.getByName("localhost"),
9595
123, "http", "", "");
96-
IVCS vcs = new GitVCS(localVCSWorkspace.getVCSRepositoryWorkspace("127.0.0.1"));
97-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
96+
IVCS vcs = new GitVCS(localVCSWorkspace.getVCSRepositoryWorkspace("localhost"));
97+
vcs.setProxy("localhost", 123, "username", "pwd");
9898

9999
PasswordAuthentication resultAuth = Authenticator.requestPasswordAuthentication(
100-
InetAddress.getByName("127.0.0.1"), 123, "http", "", "");
100+
InetAddress.getByName("localhost"), 123, "http", "", "");
101101
assertEquals(resultAuth.getUserName(), "username");
102102
assertEquals(new String(resultAuth.getPassword()), "pwd");
103103

104104
resultAuth = Authenticator.requestPasswordAuthentication(
105-
InetAddress.getByName("localhost"), 123, "http", "", "");
105+
InetAddress.getByName("localhost"), 124, "http", "", "");
106106
assertEquals(resultAuth, initialAuth);
107107
}
108108

109109
@Test
110110
public void testProxySelector() throws URISyntaxException {
111-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
111+
vcs.setProxy("localhost", 123, "username", "pwd");
112112
ProxySelector actualPS = ProxySelector.getDefault();
113113
List<Proxy> proxies = actualPS.select(new URI(vcs.getRepoUrl()));
114114
assertTrue(proxies.size() == 1);
115115
Proxy actualP = proxies.get(0);
116116
assertTrue(actualP.address() instanceof InetSocketAddress);
117117
InetSocketAddress isa = (InetSocketAddress) actualP.address();
118-
assertEquals(isa.getHostName(), "127.0.0.1");
118+
assertEquals(isa.getHostName(), "localhost");
119119
assertEquals(isa.getPort(), 123);
120120
}
121121

122122
@Test
123123
public void testParentProxySelectorUsage() throws URISyntaxException {
124124
ProxySelector mockedPS = Mockito.mock(ProxySelector.class);
125125
ProxySelector.setDefault(mockedPS);
126-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
126+
vcs.setProxy("localhost", 123, "username", "pwd");
127127
ProxySelector actualPS = ProxySelector.getDefault();
128128
URI uri = new URI("http://unknown");
129129
actualPS.select(uri);
@@ -133,7 +133,7 @@ public void testParentProxySelectorUsage() throws URISyntaxException {
133133
@Test
134134
public void testNullProxySelector() throws URISyntaxException {
135135
ProxySelector.setDefault(null);
136-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
136+
vcs.setProxy("localhost", 123, "username", "pwd");
137137
ProxySelector actualPS = ProxySelector.getDefault();
138138
List<Proxy> proxies = actualPS.select(new URI("http://unknown"));
139139
assertTrue(proxies.size() == 1);
@@ -144,7 +144,7 @@ public void testNullProxySelector() throws URISyntaxException {
144144
public void testParentSelectorCallOnConnectFailed() throws URISyntaxException {
145145
ProxySelector mockedPS = Mockito.mock(ProxySelector.class);
146146
ProxySelector.setDefault(mockedPS);
147-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
147+
vcs.setProxy("localhost", 123, "username", "pwd");
148148
ProxySelector actualPS = ProxySelector.getDefault();
149149
URI testURI = new URI("http://proxy.net");
150150
SocketAddress testSA = InetSocketAddress.createUnresolved("http://proxy.net", 123);
@@ -155,7 +155,7 @@ public void testParentSelectorCallOnConnectFailed() throws URISyntaxException {
155155
@Test
156156
public void testNoParentSelectorOnConnectFailed() throws URISyntaxException {
157157
ProxySelector.setDefault(null);
158-
vcs.setProxy("127.0.0.1", 123, "username", "pwd");
158+
vcs.setProxy("localhost", 123, "username", "pwd");
159159
ProxySelector actualPS = Mockito.spy(ProxySelector.getDefault());
160160
URI testURI = new URI("http://proxy.net");
161161
SocketAddress testSA = InetSocketAddress.createUnresolved("http://proxy.net", 123);

0 commit comments

Comments
 (0)