You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2025/08/08 02:11:39 UTC
(iotdb) 01/01: Fix error message when altering a non-exist user
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch fix_alter_user_msg
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 481f9dc33518a01c665adf9476494283dc4955f8
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Aug 8 10:11:11 2025 +0800
Fix error message when altering a non-exist user
---
.../org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java | 14 ++++++++++++++
.../org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java | 2 +-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
index 249368ac914..f2f0aef18ba 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
@@ -44,6 +44,8 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
@RunWith(IoTDBTestRunner.class)
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
public class IoTDBRelationalAuthIT {
@@ -620,4 +622,16 @@ public class IoTDBRelationalAuthIT {
Assert.fail();
}
}
+
+ @Test
+ public void testAlterNonExistingUser() throws SQLException {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement adminStmt = adminCon.createStatement()) {
+ try {
+ adminStmt.execute("ALTER USER nonExist SET PASSWORD 'asdfer1124566'");
+ } catch (SQLException e) {
+ assertEquals("701: User nonExist not found", e.getMessage());
+ }
+ }
+ }
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
index 4dbad54d51c..863a3653263 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
@@ -540,10 +540,10 @@ public class ClusterAuthorityFetcher implements IAuthorityFetcher {
} catch (ClientManagerException | TException e) {
LOGGER.error(CONNECTERROR);
}
- user = cacheUser(permissionInfoResp);
if (permissionInfoResp != null
&& permissionInfoResp.getStatus().getCode()
== TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ user = cacheUser(permissionInfoResp);
if (acceptCache) {
iAuthorCache.putUserCache(userName, user);
}