This is an automated email from the ASF dual-hosted git repository.
spricoder pushed a commit to branch refactor/new_auth
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/refactor/new_auth by this push:
new 9d75590b2e9 Fix Test
9d75590b2e9 is described below
commit 9d75590b2e9b6ce5191f1425bd539a423b35b030
Author: spricoder <[email protected]>
AuthorDate: Mon Jul 10 18:31:47 2023 +0800
Fix Test
---
.../java/org/apache/iotdb/db/it/IoTDBAuthIT.java | 4 +-
.../db/it/IoTDBSyntaxConventionIdentifierIT.java | 52 ++--------------------
.../org/apache/iotdb/commons/utils/AuthUtils.java | 8 ++--
3 files changed, 10 insertions(+), 54 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBAuthIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBAuthIT.java
index ae44cbf272f..02f89882df1 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBAuthIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBAuthIT.java
@@ -618,10 +618,10 @@ public class IoTDBAuthIT {
};
for (int i = 0; i < members.length - 1; i++) {
- adminStmt.execute("CREATE USER " + members[i] + " '666666'");
+ adminStmt.execute("CREATE USER " + members[i] + " 'a666666'");
adminStmt.execute("GRANT dalao TO " + members[i]);
}
- adminStmt.execute("CREATE USER RiverSky '2333333'");
+ adminStmt.execute("CREATE USER RiverSky 'a2333333'");
adminStmt.execute("GRANT zhazha TO RiverSky");
ResultSet resultSet = adminStmt.executeQuery("LIST USER OF ROLE dalao");
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
index c59f40d7a21..2dac13668aa 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
@@ -591,32 +591,10 @@ public class IoTDBSyntaxConventionIdentifierIT {
public void testUserName() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
- String[] userNames =
- new String[] {
- "userid",
- "userid0",
- "user_id",
- "user0id",
- "`22233`",
- "`userab!`",
- "`user'ab'`",
- "`usera.b`",
- "`usera``b`"
- };
+ String[] userNames = new String[] {"userid", "userid0", "user_id",
"user0id", "`a22233`"};
String[] resultNames =
- new String[] {
- "root",
- "userid",
- "userid0",
- "user_id",
- "user0id",
- "22233",
- "userab!",
- "user'ab'",
- "usera.b",
- "usera`b"
- };
+ new String[] {"root", "userid", "userid0", "user_id", "user0id",
"a22233"};
String createUsersSql = "create user %s 'pwd123' ";
for (String userName : userNames) {
@@ -678,31 +656,9 @@ public class IoTDBSyntaxConventionIdentifierIT {
public void testRoleName() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
- String[] roleNames =
- new String[] {
- "roleid",
- "roleid0",
- "role_id",
- "role0id",
- "`22233`",
- "`roleab!`",
- "`role'ab'`",
- "`rolea.b`",
- "`rolea``b`"
- };
+ String[] roleNames = new String[] {"roleid", "roleid0", "role_id",
"role0id", "`a22233`"};
- String[] resultNames =
- new String[] {
- "roleid",
- "roleid0",
- "role_id",
- "role0id",
- "22233",
- "roleab!",
- "role'ab'",
- "rolea.b",
- "rolea`b"
- };
+ String[] resultNames = new String[] {"roleid", "roleid0", "role_id",
"role0id", "a22233"};
String createRolesSql = "create role %s";
for (String roleName : roleNames) {
statement.execute(String.format(createRolesSql, roleName));
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/AuthUtils.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/AuthUtils.java
index e500f0ed2b9..1acd6e6d698 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/AuthUtils.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/AuthUtils.java
@@ -51,8 +51,8 @@ public class AuthUtils {
private static final String ROOT_PREFIX = IoTDBConstant.PATH_ROOT;
public static PartialPath ROOT_PATH_PRIVILEGE_PATH;
private static final int MIN_LENGTH = 4;
- private static final int MAX_LENGTH = 32;
- private static final String REX_PATTERN = "^[a-zA-Z]\\w*$";
+ private static final int MAX_LENGTH = 64;
+ private static final String REX_PATTERN = "^[a-zA-Z][-\\w]*$";
static {
try {
@@ -129,8 +129,8 @@ public class AuthUtils {
} else if (!str.matches(REX_PATTERN)) {
throw new AuthException(
TSStatusCode.ILLEGAL_PARAMETER,
- "The name or password must start with a letter and can only contain
letters, numbers,"
- + " and underscores");
+ "The name or password can only contain letters, numbers, and
underscores, "
+ + "and cannot start with numbers");
}
}