yuqi1129 commented on code in PR #10081:
URL: https://github.com/apache/gravitino/pull/10081#discussion_r2966499193


##########
core/src/test/java/org/apache/gravitino/credential/TestJdbcCredentialProvider.java:
##########
@@ -0,0 +1,102 @@
+/*
+ *  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.gravitino.credential;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestJdbcCredentialProvider {
+
+  @Test
+  void testJdbcCredentialProvider() {
+    String jdbcUser = "test-user";
+    String jdbcPassword = "test-password";
+    Map<String, String> catalogProperties =
+        ImmutableMap.of(
+            JdbcCredential.GRAVITINO_JDBC_USER,
+            jdbcUser,
+            JdbcCredential.GRAVITINO_JDBC_PASSWORD,
+            jdbcPassword);
+
+    CredentialProvider credentialProvider =
+        CredentialProviderFactory.create(JdbcCredential.JDBC_CREDENTIAL_TYPE, 
catalogProperties);

Review Comment:
   Missing test cases for edge conditions:
   
   1. **Partial credentials** — only user set, password absent (expect 
`getCredential()` returns `null`)
   2. **Empty string credentials** — `""` vs `null` behavior (both should 
result in `null` return since `JdbcCredentialProvider` does `== null` check, 
not `isBlank`)
   3. **`properties` map is `null`** — verify NPE is thrown or handled 
gracefully
   
   Example:
   ```java
   @Test
   void testPartialCredentials() {
       Map<String, String> props = new HashMap<>();
       props.put(JdbcCredential.GRAVITINO_JDBC_USER, "user");
       // password deliberately missing
       provider.initialize(props);
       Assertions.assertNull(provider.getCredential(null));
   }
   ```
   
   Note: the `== null` check in `getCredential()` will return `null` for absent 
keys but NOT for empty-string values. If empty passwords should also be 
rejected, the check should use `isBlank` there too.



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