davsclaus commented on code in PR #31030:
URL: https://github.com/apache/camel/pull/31030#discussion_r4722750003
##########
components/camel-ai/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusEndpoint.java:
##########
@@ -185,14 +186,55 @@ public void doStop() throws Exception {
}
private MilvusClient createClient() {
+ return new MilvusServiceClient(createConnectParam());
+ }
+ ConnectParam createConnectParam() {
ConnectParam.Builder parameters =
ConnectParam.newBuilder().withHost(configuration.getHost())
.withPort(configuration.getPort()).withConnectTimeout(configuration.getTimeout(),
TimeUnit.MILLISECONDS);
if (configuration.getToken() != null) {
parameters.withToken(configuration.getToken());
}
- return new MilvusServiceClient(parameters.build());
+ parameters.withSecure(configuration.isSecure());
Review Comment:
No change: in SDK 2.6.28 both `withSecure(boolean)` and `secure(boolean)`
are deprecated, and the only other way to get TLS without the cert files is
`withUri("https://host:port")`, which re-parses host and port through
`java.net.URI` (an IPv6 host would need brackets and come back in another
form). Calling `withSecure` keeps the `host`/`port` options as they are. We can
drop it when we move to the v2 `MilvusClientV2` / SDK 3 API.
_Claude Code on behalf of davsclaus_
##########
components/camel-ai/camel-milvus/src/test/java/org/apache/camel/component/milvus/MilvusConnectParamTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.milvus;
+
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import io.milvus.client.MilvusServiceClient;
+import io.milvus.param.ConnectParam;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * The TLS options of the endpoint reach the ConnectParam of the Milvus SDK.
No Milvus server is needed.
+ */
+public class MilvusConnectParamTest extends CamelTestSupport {
+
+ @Test
+ public void plaintextByDefault() {
+ ConnectParam param =
connectParam("milvus:test?host=milvus.example.com&port=19531&token=user:secret");
+
+ assertThat(param.getHost()).isEqualTo("milvus.example.com");
+ assertThat(param.getPort()).isEqualTo(19531);
+ assertThat(param.isSecure()).isFalse();
+ assertThat(param.getServerPemPath()).isNull();
+ assertThat(param.getServerName()).isNull();
+ assertThat(param.getCaPemPath()).isNull();
+ assertThat(param.getClientPemPath()).isNull();
+ assertThat(param.getClientKeyPath()).isNull();
+ }
+
+ @Test
+ public void secure() {
+ ConnectParam param =
connectParam("milvus:test?host=milvus.example.com&secure=true");
+
+ assertThat(param.isSecure()).isTrue();
+ assertThat(param.getServerPemPath()).isNull();
+ assertThat(param.getCaPemPath()).isNull();
+ }
+
+ @Test
+ public void serverPemPath() {
Review Comment:
Done in dce34c4003df: `serverPemPath()` and `mutualTls()` no longer set
`secure=true` and still assert `isSecure()`, so they cover the documented
implicit TLS. `secure()` and `serverPemPathAndServerName()` keep the explicit
option.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]