|
25 | 25 | import java.net.InetSocketAddress; |
26 | 26 | import java.net.ProxySelector; |
27 | 27 | import java.net.URI; |
| 28 | +import java.security.NoSuchAlgorithmException; |
28 | 29 | import java.time.Instant; |
29 | 30 | import java.util.Map; |
30 | 31 | import java.util.Properties; |
31 | 32 | import java.util.UUID; |
32 | 33 | import java.util.stream.Stream; |
| 34 | +import javax.net.ssl.SSLContext; |
| 35 | +import javax.net.ssl.SSLException; |
33 | 36 |
|
34 | 37 | import io.grpc.HttpConnectProxiedSocketAddress; |
35 | 38 | import io.grpc.ProxyDetector; |
| 39 | +import io.netty.handler.ssl.SslContext; |
36 | 40 | import org.assertj.core.api.Assertions; |
37 | 41 | import org.junit.jupiter.api.Test; |
38 | 42 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; |
|
43 | 47 |
|
44 | 48 | public class InfluxDBClientTest { |
45 | 49 |
|
| 50 | + @Test |
| 51 | + void testCustomSslContext() throws NoSuchAlgorithmException, SSLException { |
| 52 | + // Test for java.net SslContext |
| 53 | + ClientConfig.Builder builder = new ClientConfig.Builder(); |
| 54 | + ClientConfig clientConfig = builder.sslContext(null).build(); |
| 55 | + Assertions.assertThat(clientConfig.getSslContext()).isNull(); |
| 56 | + |
| 57 | + clientConfig = builder.sslContext(SSLContext.getDefault()).build(); |
| 58 | + Assertions.assertThat(clientConfig.getSslContext()).isNotNull(); |
| 59 | + |
| 60 | + // Test for grpc SslContext |
| 61 | + ClientConfig.Builder builder1 = new ClientConfig.Builder(); |
| 62 | + ClientConfig clientConfig1 = builder1.grpcSslContext(null).build(); |
| 63 | + Assertions.assertThat(clientConfig1.getGrpcSslContext()).isNull(); |
| 64 | + |
| 65 | + clientConfig1 = builder1.grpcSslContext(SslContext.newClientContext()).build(); |
| 66 | + Assertions.assertThat(clientConfig1.getGrpcSslContext()).isNotNull(); |
| 67 | + } |
| 68 | + |
46 | 69 | @EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*") |
47 | 70 | @EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*") |
48 | 71 | @EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*") |
|
0 commit comments