ramu11 commented on code in PR #27168:
URL: https://github.com/apache/camel/pull/27168#discussion_r4156209888


##########
components/camel-odata/src/test/java/org/apache/camel/component/odata/ODataEndpointTest.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.odata;
+
+import java.net.URI;
+
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ODataEndpointTest extends CamelTestSupport {
+
+    @Test
+    void testEndpointUriConfiguration() throws Exception {
+        ODataEndpoint endpoint = context.getEndpoint(
+                "odata:http://localhost:8080/odata/Products";, 
ODataEndpoint.class);
+
+        assertNotNull(endpoint);
+        assertEquals(new URI("http://localhost:8080/odata/Products";), 
endpoint.getHttpUri());
+        assertNotNull(endpoint.createProducer());
+    }
+
+    @Test
+    void testEndpointWithQueryParameters() throws Exception {
+        ODataEndpoint endpoint = context.getEndpoint(
+                
"odata:http://localhost:8080/odata/Products?top=10&filter=Name%20eq%20'Test'", 
ODataEndpoint.class);
+
+        assertNotNull(endpoint);
+        assertEquals(new URI("http://localhost:8080/odata/Products";), 
endpoint.getHttpUri());
+        assertEquals(10, endpoint.getConfiguration().getTop());
+        assertEquals("Name eq 'Test'", 
endpoint.getConfiguration().getFilter());
+    }
+
+    @Test
+    void testEndpointSchemeAndMetadata() throws Exception {
+        ODataEndpoint endpoint = context.getEndpoint(
+                "odata:http://localhost:8080/odata/Products";, 
ODataEndpoint.class);
+
+        assertEquals("odata", endpoint.getEndpointKey().split(":")[0]);
+        assertEquals("odata://http://localhost:8080/odata/Products";, 
endpoint.getEndpointUri());
+    }
+
+    @Test
+    void testSecretMaskingInUriAndToString() {
+        String rawUri
+                = 
"odata:http://localhost:8080/odata/Products?authUsername=user&authPassword=secretPassword&authBearerToken=myToken";;
+        ODataEndpoint endpoint = context.getEndpoint(rawUri, 
ODataEndpoint.class);
+
+        assertNotNull(endpoint);
+
+        // toString() must mask secrets
+        String toString = endpoint.toString();
+        assertFalse(toString.contains("secretPassword"), "toString() should 
not reveal authPassword");
+        assertFalse(toString.contains("myToken"), "toString() should not 
reveal authBearerToken");
+        assertTrue(toString.contains("authPassword=xxxxxx") || 
toString.contains("authPassword=******"));
+
+        // Check URISupport sanitization directly if testing Camel's URI 
masking utility
+        String sanitizedUri = 
org.apache.camel.util.URISupport.sanitizeUri(endpoint.getEndpointUri());

Review Comment:
   Addressed in commit `c1a11055ded4`.
   
   Imported `org.apache.camel.util.URISupport` and replaced the fully qualified 
reference with `URISupport.sanitizeUri(...)`.
   



-- 
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]

Reply via email to