|
42 | 42 | import org.springframework.context.annotation.Bean; |
43 | 43 | import org.springframework.context.annotation.Configuration; |
44 | 44 | import org.springframework.context.annotation.DependsOn; |
| 45 | +import org.springframework.util.StringUtils; |
45 | 46 | import reactor.core.publisher.Mono; |
46 | 47 |
|
47 | 48 | import java.security.SecureRandom; |
@@ -85,17 +86,26 @@ DefaultConnectionContext connectionContext(@Value("${test.apiHost}") String apiH |
85 | 86 | @Value("${test.proxy.username:}") String proxyUsername, |
86 | 87 | @Value("${test.skipSslValidation:false}") Boolean skipSslValidation) { |
87 | 88 |
|
88 | | - return DefaultConnectionContext.builder() |
| 89 | + DefaultConnectionContext.Builder connectionContext = DefaultConnectionContext.builder() |
89 | 90 | .apiHost(apiHost) |
90 | 91 | .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() |
92 | 96 | .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(); |
99 | 109 | } |
100 | 110 |
|
101 | 111 | @Bean |
|
0 commit comments