Skip to content

Commit 1132eb5

Browse files
committed
Integration Test Proxy Configuration
This change updates the proxy configuration to compensate for the fact that Reactor doesn't handle empty strings as `null`.
1 parent d8de095 commit 1132eb5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

integration-test/src/test/java/org/cloudfoundry/IntegrationTestConfiguration.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.context.annotation.Bean;
4343
import org.springframework.context.annotation.Configuration;
4444
import org.springframework.context.annotation.DependsOn;
45+
import org.springframework.util.StringUtils;
4546
import reactor.core.publisher.Mono;
4647

4748
import java.security.SecureRandom;
@@ -85,17 +86,26 @@ DefaultConnectionContext connectionContext(@Value("${test.apiHost}") String apiH
8586
@Value("${test.proxy.username:}") String proxyUsername,
8687
@Value("${test.skipSslValidation:false}") Boolean skipSslValidation) {
8788

88-
return DefaultConnectionContext.builder()
89+
DefaultConnectionContext.Builder connectionContext = DefaultConnectionContext.builder()
8990
.apiHost(apiHost)
9091
.problemHandler(new FailingDeserializationProblemHandler()) // Test-only problem handler
91-
.proxyConfiguration(ProxyConfiguration.builder()
92+
.skipSslValidation(skipSslValidation);
93+
94+
if (StringUtils.hasText(proxyHost)) {
95+
ProxyConfiguration.Builder proxyConfiguration = ProxyConfiguration.builder()
9296
.host(proxyHost)
93-
.password(proxyPassword)
94-
.port(proxyPort)
95-
.username(proxyUsername)
96-
.build())
97-
.skipSslValidation(skipSslValidation)
98-
.build();
97+
.port(proxyPort);
98+
99+
if (StringUtils.hasText(proxyUsername)) {
100+
proxyConfiguration
101+
.password(proxyPassword)
102+
.username(proxyUsername);
103+
}
104+
105+
connectionContext.proxyConfiguration(proxyConfiguration.build());
106+
}
107+
108+
return connectionContext.build();
99109
}
100110

101111
@Bean

0 commit comments

Comments
 (0)