|
6 | 6 | import static junit.framework.TestCase.assertTrue; |
7 | 7 |
|
8 | 8 | import androidx.annotation.NonNull; |
| 9 | +import androidx.annotation.Nullable; |
9 | 10 |
|
10 | 11 | import org.junit.Test; |
11 | 12 |
|
|
14 | 15 | import java.util.concurrent.TimeUnit; |
15 | 16 |
|
16 | 17 | import io.split.android.client.network.CertificatePinningConfiguration; |
| 18 | +import io.split.android.client.network.ProxyConfiguration; |
| 19 | +import io.split.android.client.network.SplitAuthenticatedRequest; |
| 20 | +import io.split.android.client.network.SplitAuthenticator; |
17 | 21 | import io.split.android.client.utils.logger.LogPrinter; |
18 | 22 | import io.split.android.client.utils.logger.Logger; |
19 | 23 | import io.split.android.client.utils.logger.SplitLogLevel; |
@@ -256,6 +260,47 @@ public void nullRolloutCacheConfigurationSetsDefault() { |
256 | 260 | assertEquals(1, logMessages.size()); |
257 | 261 | } |
258 | 262 |
|
| 263 | + @Test |
| 264 | + public void proxyHostAndProxyConfigurationSetLogWarning() { |
| 265 | + Queue<String> logMessages = getLogMessagesQueue(); |
| 266 | + SplitClientConfig.builder() |
| 267 | + .logLevel(SplitLogLevel.WARNING) |
| 268 | + .proxyHost("proxyHost") |
| 269 | + .proxyConfiguration(ProxyConfiguration.builder().url("http://proxy.url").build()) |
| 270 | + .build(); |
| 271 | + assertEquals(1, logMessages.size()); |
| 272 | + assertEquals("Both the deprecated proxy configuration methods (proxyHost, proxyAuthenticator) and the new ProxyConfiguration builder are being used. ProxyConfiguration will take precedence.", logMessages.poll()); |
| 273 | + } |
| 274 | + |
| 275 | + @Test |
| 276 | + public void proxyAuthenticatorAndProxyConfigurationSetLogWarning() { |
| 277 | + Queue<String> logMessages = getLogMessagesQueue(); |
| 278 | + SplitClientConfig.builder() |
| 279 | + .logLevel(SplitLogLevel.WARNING) |
| 280 | + .proxyAuthenticator(new SplitAuthenticator() { |
| 281 | + @Nullable |
| 282 | + @Override |
| 283 | + public SplitAuthenticatedRequest authenticate(@NonNull SplitAuthenticatedRequest request) { |
| 284 | + return null; |
| 285 | + } |
| 286 | + }) |
| 287 | + .proxyConfiguration(ProxyConfiguration.builder().url("http://proxy.url").build()) |
| 288 | + .build(); |
| 289 | + assertEquals(1, logMessages.size()); |
| 290 | + assertEquals("Both the deprecated proxy configuration methods (proxyHost, proxyAuthenticator) and the new ProxyConfiguration builder are being used. ProxyConfiguration will take precedence.", logMessages.poll()); |
| 291 | + } |
| 292 | + |
| 293 | + @Test |
| 294 | + public void proxyConfigurationWithNoUrlSetLogWarning() { |
| 295 | + Queue<String> logMessages = getLogMessagesQueue(); |
| 296 | + SplitClientConfig.builder() |
| 297 | + .logLevel(SplitLogLevel.WARNING) |
| 298 | + .proxyConfiguration(ProxyConfiguration.builder().build()) |
| 299 | + .build(); |
| 300 | + assertEquals(1, logMessages.size()); |
| 301 | + assertEquals("Proxy configuration with no URL. This will prevent SplitFactory from working.", logMessages.poll()); |
| 302 | + } |
| 303 | + |
259 | 304 | @NonNull |
260 | 305 | private static Queue<String> getLogMessagesQueue() { |
261 | 306 | Queue<String> logMessages = new LinkedList<>(); |
|
0 commit comments