Skip to content

Commit d5d4130

Browse files
wip
1 parent 3d323a1 commit d5d4130

File tree

8 files changed

+4
-120
lines changed

8 files changed

+4
-120
lines changed

examples/src/main/java/com/influxdb/v3/ProxyExample.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ public static void main(final String[] args) throws Exception {
6464
ProxyDetector proxyDetector = createProxyDetector(targetUrl, proxyUrl, username, password);
6565
nettyHttpClientConfig.configureManagedChannelProxy(proxyDetector);
6666

67-
String sslRootsFilePath = "src/test/java/com/influxdb/v3/client/testdata/influxdb-certificate.pem";
6867
ClientConfig clientConfig = new ClientConfig.Builder()
6968
.host(System.getenv("INFLUXDB_URL"))
7069
.token(System.getenv("INFLUXDB_TOKEN").toCharArray())
7170
.database(System.getenv("INFLUXDB_DATABASE"))
7271
.nettyHttpClientConfig(nettyHttpClientConfig)
73-
.sslRootsFilePath(sslRootsFilePath)
7472
.build();
7573

7674
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {

src/main/java/com/influxdb/v3/client/config/ClientConfig.java

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@
5858
* <li><code>queryTimeout</code> - timeout used to calculate a default gRPC deadline when querying InfluxDB.
5959
* Can be <code>null</code>, in which case queries can potentially run forever.</li>
6060
* <li><code>allowHttpRedirects</code> - allow redirects for InfluxDB connections</li>
61-
* <li><code>disableServerCertificateValidation</code> -
62-
* disable server certificate validation for HTTPS connections
63-
* </li>
6461
* <li><code>headers</code> - headers to be added to requests</li>
65-
* <li><code>sslRootsFilePath</code> - path to the stored certificates file in PEM format</li>
6662
* <li><code>disableGRPCCompression</code> - disables the default gRPC compression header</li>
6763
* </ul>
6864
* <p>
@@ -104,9 +100,7 @@ public final class ClientConfig {
104100
private final Duration writeTimeout;
105101
private final Duration queryTimeout;
106102
private final Boolean allowHttpRedirects;
107-
private final Boolean disableServerCertificateValidation;
108103
private final Map<String, String> headers;
109-
private final String sslRootsFilePath;
110104
private final boolean disableGRPCCompression;
111105
private final NettyHttpClientConfig nettyHttpClientConfig;
112106

@@ -247,27 +241,6 @@ public Boolean getAllowHttpRedirects() {
247241
return allowHttpRedirects;
248242
}
249243

250-
/**
251-
* Gets the disable server SSL certificate validation. Default to 'false'.
252-
*
253-
* @return the disable server SSL certificate validation
254-
*/
255-
@Nonnull
256-
public Boolean getDisableServerCertificateValidation() {
257-
return disableServerCertificateValidation;
258-
}
259-
260-
/**
261-
* Gets certificates file path.
262-
*
263-
* @return the certificates file path, may be null
264-
*/
265-
@Nullable
266-
public String sslRootsFilePath() {
267-
return sslRootsFilePath;
268-
}
269-
270-
271244
/**
272245
* Gets custom headers for requests.
273246
*
@@ -323,18 +296,16 @@ public boolean equals(final Object o) {
323296
&& Objects.equals(writeTimeout, that.writeTimeout)
324297
&& Objects.equals(queryTimeout, that.queryTimeout)
325298
&& Objects.equals(allowHttpRedirects, that.allowHttpRedirects)
326-
&& Objects.equals(disableServerCertificateValidation, that.disableServerCertificateValidation)
327299
&& Objects.equals(headers, that.headers)
328-
&& Objects.equals(sslRootsFilePath, that.sslRootsFilePath)
329300
&& disableGRPCCompression == that.disableGRPCCompression;
330301
}
331302

332303
@Override
333304
public int hashCode() {
334305
return Objects.hash(host, Arrays.hashCode(token), authScheme, organization,
335306
database, writePrecision, gzipThreshold, writeNoSync,
336-
timeout, writeTimeout, queryTimeout, allowHttpRedirects, disableServerCertificateValidation,
337-
headers, defaultTags, sslRootsFilePath, disableGRPCCompression);
307+
timeout, writeTimeout, queryTimeout, allowHttpRedirects,
308+
headers, defaultTags, disableGRPCCompression);
338309
}
339310

340311
@Override
@@ -350,10 +321,8 @@ public String toString() {
350321
.add("writeTimeout=" + writeTimeout)
351322
.add("queryTimeout=" + queryTimeout)
352323
.add("allowHttpRedirects=" + allowHttpRedirects)
353-
.add("disableServerCertificateValidation=" + disableServerCertificateValidation)
354324
.add("headers=" + headers)
355325
.add("defaultTags=" + defaultTags)
356-
.add("sslRootsFilePath=" + sslRootsFilePath)
357326
.add("disableGRPCCompression=" + disableGRPCCompression)
358327
.toString();
359328
}
@@ -378,9 +347,7 @@ public static final class Builder {
378347
private Duration writeTimeout;
379348
private Duration queryTimeout;
380349
private Boolean allowHttpRedirects;
381-
private Boolean disableServerCertificateValidation;
382350
private Map<String, String> headers;
383-
private String sslRootsFilePath;
384351
private boolean disableGRPCCompression;
385352
private NettyHttpClientConfig nettyHttpClientConfig;
386353

@@ -566,19 +533,6 @@ public Builder allowHttpRedirects(@Nullable final Boolean allowHttpRedirects) {
566533
return this;
567534
}
568535

569-
/**
570-
* Sets the disable server SSL certificate validation. Default to 'false'.
571-
*
572-
* @param disableServerCertificateValidation Disable server SSL certificate validation. Default to 'false'.
573-
* @return this
574-
*/
575-
@Nonnull
576-
public Builder disableServerCertificateValidation(@Nullable final Boolean disableServerCertificateValidation) {
577-
578-
this.disableServerCertificateValidation = disableServerCertificateValidation;
579-
return this;
580-
}
581-
582536
/**
583537
* Sets the custom headers that will be added to requests. This is useful for adding custom headers to requests,
584538
* such as tracing headers. To add custom headers use following code:
@@ -611,19 +565,6 @@ public Builder headers(@Nullable final Map<String, String> headers) {
611565
return this;
612566
}
613567

614-
/**
615-
* Sets certificate file path. Default is 'null'.
616-
*
617-
* @param sslRootsFilePath The certificate file path
618-
* @return this
619-
*/
620-
@Nonnull
621-
public Builder sslRootsFilePath(@Nullable final String sslRootsFilePath) {
622-
623-
this.sslRootsFilePath = sslRootsFilePath;
624-
return this;
625-
}
626-
627568
/**
628569
* Sets whether to disable gRPC compression. Default is 'false'.
629570
*
@@ -808,10 +749,7 @@ private ClientConfig(@Nonnull final Builder builder) {
808749
? builder.timeout : Duration.ofSeconds(WriteOptions.DEFAULT_WRITE_TIMEOUT);
809750
queryTimeout = builder.queryTimeout;
810751
allowHttpRedirects = builder.allowHttpRedirects != null ? builder.allowHttpRedirects : false;
811-
disableServerCertificateValidation = builder.disableServerCertificateValidation != null
812-
? builder.disableServerCertificateValidation : false;
813752
headers = builder.headers;
814-
sslRootsFilePath = builder.sslRootsFilePath;
815753
disableGRPCCompression = builder.disableGRPCCompression;
816754
nettyHttpClientConfig = builder.nettyHttpClientConfig;
817755
}

src/main/java/com/influxdb/v3/client/internal/RestClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ final class RestClient implements AutoCloseable {
146146
// default headers
147147
this.defaultHeaders = config.getHeaders() != null ? Map.copyOf(config.getHeaders()) : null;
148148

149-
//fixme `clientHandler`should store in a list and pass to `ClientChannelInitializer()`
150149
this.clientHandler = new ClientHandler();
151150

152151
if (this.config.getNettyHttpClientConfig() != null

src/test/java/com/influxdb/v3/client/InfluxDBClientTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131

3232
public class InfluxDBClientTest {
3333

34-
@Test
35-
void withSslRootsFilePath() {
36-
String path = "/path/to/cert";
37-
ClientConfig.Builder builder = new ClientConfig.Builder();
38-
builder.sslRootsFilePath(path);
39-
ClientConfig clientConfig = builder.build();
40-
Assertions.assertThat(clientConfig.sslRootsFilePath()).isEqualTo(path);
41-
}
42-
4334
@Test
4435
void requiredHost() {
4536

src/test/java/com/influxdb/v3/client/TestUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private TestUtils() {
7373

7474
public static FlightServer simpleFlightServer(@Nonnull final URI uri,
7575
@Nonnull final BufferAllocator allocator,
76-
@Nonnull final NoOpFlightProducer producer) throws Exception {
76+
@Nonnull final NoOpFlightProducer producer) {
7777
Location location = Location.forGrpcInsecure(uri.getHost(), uri.getPort());
7878
return FlightServer.builder(allocator, location, producer).build();
7979
}
@@ -114,8 +114,6 @@ public static VectorSchemaRoot generateVectorSchemaRoot(final int fieldCount, fi
114114
return vectorSchemaRoot;
115115
}
116116

117-
118-
// fixme
119117
// Create SslContext for mTLS only
120118
public static SslContext createNettySslContext(final boolean isServer, final String format, final String password,
121119
final String keyFilePath,

src/test/java/com/influxdb/v3/client/config/ClientConfigTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class ClientConfigTest {
4545
.writeTimeout(Duration.ofSeconds(35))
4646
.queryTimeout(Duration.ofSeconds(120))
4747
.allowHttpRedirects(true)
48-
.disableServerCertificateValidation(true)
4948
.headers(Map.of("X-device", "ab-01"))
5049
.disableGRPCCompression(true);
5150

src/test/java/com/influxdb/v3/client/integration/E2ETest.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -118,44 +118,6 @@ void testQueryWithProxy() throws URISyntaxException, SSLException {
118118
}
119119
}
120120

121-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*")
122-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*")
123-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*")
124-
@Test
125-
void correctSslCertificates() throws Exception {
126-
// This is real certificate downloaded from https://cloud2.influxdata.com
127-
String influxDBcertificateFile = "src/test/java/com/influxdb/v3/client/testdata/influxdb-certificate.pem";
128-
129-
ClientConfig clientConfig = new ClientConfig.Builder()
130-
.host(System.getenv("TESTING_INFLUXDB_URL"))
131-
.token(System.getenv("TESTING_INFLUXDB_TOKEN").toCharArray())
132-
.database(System.getenv("TESTING_INFLUXDB_DATABASE"))
133-
.sslRootsFilePath(influxDBcertificateFile)
134-
.build();
135-
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
136-
assertGetDataSuccess(influxDBClient);
137-
}
138-
139-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*")
140-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*")
141-
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*")
142-
@Test
143-
void disableServerCertificateValidation() throws URISyntaxException, SSLException {
144-
String wrongCertificateFile = "src/test/java/com/influxdb/v3/client/testdata/docker.com.pem";
145-
146-
ClientConfig clientConfig = new ClientConfig.Builder()
147-
.host(System.getenv("TESTING_INFLUXDB_URL"))
148-
.token(System.getenv("TESTING_INFLUXDB_TOKEN").toCharArray())
149-
.database(System.getenv("TESTING_INFLUXDB_DATABASE"))
150-
.disableServerCertificateValidation(true)
151-
.sslRootsFilePath(wrongCertificateFile)
152-
.build();
153-
154-
// Test succeeded with wrong certificate file because disableServerCertificateValidation is true
155-
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
156-
assertGetDataSuccess(influxDBClient);
157-
}
158-
159121
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*")
160122
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*")
161123
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*")

src/test/java/com/influxdb/v3/client/internal/RestClientTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@ public void getServerVersionErrorNoBody()
520520
@Test
521521
public void nettyRestMutualSslContext()
522522
throws ExecutionException, InterruptedException, URISyntaxException, IOException, UnrecoverableKeyException,
523-
CertificateException, KeyStoreException, NoSuchAlgorithmException, CertificateException, KeyStoreException,
524-
NoSuchAlgorithmException {
523+
CertificateException, KeyStoreException, NoSuchAlgorithmException {
525524
var password = "123456";
526525
var format = "PKCS12";
527526

0 commit comments

Comments
 (0)