Skip to content

Commit b8947ff

Browse files
authored
Delete Maintain Auth
1 parent 1669f50 commit b8947ff

File tree

23 files changed

+180
-233
lines changed

23 files changed

+180
-233
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,21 @@ public void testClusterManagementSqlOfTableModel() throws Exception {
13581358
try (Connection JackConnection =
13591359
EnvFactory.getEnv().getConnection("Jack", "temppw", BaseEnv.TABLE_SQL_DIALECT);
13601360
Statement Jack = JackConnection.createStatement()) {
1361-
testClusterManagementSqlImpl(
1362-
clusterManagementSQLList, () -> adminStmt.execute("GRANT MAINTAIN TO USER Jack"), Jack);
1361+
// Jack has no authority to execute these SQLs
1362+
for (String sql : clusterManagementSQLList) {
1363+
try {
1364+
Jack.execute(sql);
1365+
} catch (IoTDBSQLException e) {
1366+
if (TSStatusCode.NO_PERMISSION.getStatusCode() != e.getErrorCode()) {
1367+
fail(
1368+
String.format(
1369+
"SQL should fail because of no permission, but the error code is %d: %s",
1370+
e.getErrorCode(), sql));
1371+
}
1372+
continue;
1373+
}
1374+
fail(String.format("SQL should fail because of no permission: %s", sql));
1375+
}
13631376
}
13641377
}
13651378
}

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBClusterAuthorityRelationalIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ public void permissionTest()
348348
false));
349349
grantSysPrivilegeAndCheck(client, "user1", "role1", true, PrivilegeType.MANAGE_USER, false);
350350
grantSysPrivilegeAndCheck(client, "user1", "role1", true, PrivilegeType.MANAGE_ROLE, true);
351-
grantSysPrivilegeAndCheck(client, "user1", "role1", false, PrivilegeType.MAINTAIN, true);
352351
grantPrivilegeAndCheck(
353352
client, "user1", "", true, new PrivilegeUnion("database", "table", PrivilegeType.SELECT));
354353
grantPrivilegeAndCheck(

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public void checkAuthorStatementPrivilegeCheck() throws SQLException {
154154
// admin can do all things below.
155155
adminStmt.execute("GRANT MANAGE_USER to user testuser2 with grant option");
156156
adminStmt.execute("GRANT MANAGE_ROLE to user testuser");
157-
adminStmt.execute("GRANT MAINTAIN to ROLE testrole with grant option");
158157

159158
adminStmt.execute("use testdb");
160159
adminStmt.execute("GRANT SELECT ON TABLE TB to user testuser");
@@ -179,7 +178,6 @@ public void checkAuthorStatementPrivilegeCheck() throws SQLException {
179178
// testdb.* insert
180179
// any alter
181180
// manage_role
182-
// MAINTAIN with grant option
183181

184182
// cannot create user
185183
Assert.assertThrows(
@@ -210,7 +208,6 @@ public void checkAuthorStatementPrivilegeCheck() throws SQLException {
210208
() -> {
211209
userStmt.execute("GRANT manage_role to role testrole2");
212210
});
213-
userStmt.execute("GRANT MAINTAIN to ROLE testrole2");
214211

215212
// can list itself privileges and the all roles privileges
216213
ResultSet rs = userStmt.executeQuery("List privileges of user testuser");
@@ -221,15 +218,13 @@ public void checkAuthorStatementPrivilegeCheck() throws SQLException {
221218
",*.*,ALTER,false,",
222219
",testdb.*,INSERT,false,",
223220
",testdb.tb,SELECT,false,",
224-
",testdb.tb,INSERT,false,",
225-
"testrole2,,MAINTAIN,false,",
226-
"testrole,,MAINTAIN,true,"));
221+
",testdb.tb,INSERT,false,"));
227222
TestUtils.assertResultSetEqual(rs, "Role,Scope,Privileges,GrantOption,", ans);
228223
rs = userStmt.executeQuery("List privileges of role testrole");
229-
ans = new HashSet<>(Collections.singletonList("testrole,,MAINTAIN,true,"));
224+
ans = new HashSet<>();
230225
TestUtils.assertResultSetEqual(rs, "Role,Scope,Privileges,GrantOption,", ans);
231226
rs = userStmt.executeQuery("List privileges of role testrole2");
232-
ans = new HashSet<>(Collections.singletonList("testrole2,,MAINTAIN,false,"));
227+
ans = new HashSet<>();
233228
TestUtils.assertResultSetEqual(rs, "Role,Scope,Privileges,GrantOption,", ans);
234229
// testdb.TB's privilege is not grant option.
235230
Assert.assertThrows(

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/basic/IoTDBPipeLifeCycleIT.java

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
package org.apache.iotdb.pipe.it.dual.tablemodel.manual.basic;
2121

2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
23-
import org.apache.iotdb.commons.auth.entity.PrivilegeType;
2423
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
2524
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq;
2625
import org.apache.iotdb.db.it.utils.TestUtils;
2726
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
2827
import org.apache.iotdb.it.framework.IoTDBTestRunner;
2928
import org.apache.iotdb.itbase.category.MultiClusterIT2DualTableManualBasic;
30-
import org.apache.iotdb.itbase.env.BaseEnv;
3129
import org.apache.iotdb.pipe.it.dual.tablemodel.TableModelUtils;
3230
import org.apache.iotdb.pipe.it.dual.tablemodel.manual.AbstractPipeTableModelDualManualIT;
3331
import org.apache.iotdb.rpc.TSStatusCode;
@@ -39,7 +37,6 @@
3937
import org.junit.experimental.categories.Category;
4038
import org.junit.runner.RunWith;
4139

42-
import java.util.Arrays;
4340
import java.util.Collections;
4441
import java.util.HashMap;
4542
import java.util.Map;
@@ -49,10 +46,7 @@
4946
import static org.apache.iotdb.db.it.utils.TestUtils.assertTableNonQueryTestFail;
5047
import static org.apache.iotdb.db.it.utils.TestUtils.assertTableTestFail;
5148
import static org.apache.iotdb.db.it.utils.TestUtils.createUser;
52-
import static org.apache.iotdb.db.it.utils.TestUtils.executeNonQueriesWithRetry;
5349
import static org.apache.iotdb.db.it.utils.TestUtils.executeNonQueryWithRetry;
54-
import static org.apache.iotdb.db.it.utils.TestUtils.executeQueryWithRetry;
55-
import static org.apache.iotdb.db.it.utils.TestUtils.grantUserSystemPrivileges;
5650

5751
@RunWith(IoTDBTestRunner.class)
5852
@Category({MultiClusterIT2DualTableManualBasic.class})
@@ -725,91 +719,59 @@ public void testPermission() {
725719
+ " 'connector.ip'='127.0.0.1',\n"
726720
+ " 'connector.port'='6668'\n"
727721
+ ")",
728-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
722+
"803: Access Denied: No permissions for this operation, only root user is allowed",
729723
"test",
730724
"test123",
731725
null);
732726
assertTableNonQueryTestFail(
733727
senderEnv,
734728
"drop pipe testPipe",
735-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
729+
"803: Access Denied: No permissions for this operation, only root user is allowed",
736730
"test",
737731
"test123",
738732
null);
739733
assertTableTestFail(
740734
senderEnv,
741735
"show pipes",
742-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
736+
"803: Access Denied: No permissions for this operation, only root user is allowed",
743737
"test",
744738
"test123",
745739
null);
746740
assertTableNonQueryTestFail(
747741
senderEnv,
748742
"start pipe testPipe",
749-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
743+
"803: Access Denied: No permissions for this operation, only root user is allowed",
750744
"test",
751745
"test123",
752746
null);
753747
assertTableNonQueryTestFail(
754748
senderEnv,
755749
"stop pipe testPipe",
756-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
750+
"803: Access Denied: No permissions for this operation, only root user is allowed",
757751
"test",
758752
"test123",
759753
null);
760754

761755
assertTableNonQueryTestFail(
762756
senderEnv,
763757
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'xxx'",
764-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
758+
"803: Access Denied: No permissions for this operation, only root user is allowed",
765759
"test",
766760
"test123",
767761
null);
768762
assertTableNonQueryTestFail(
769763
senderEnv,
770764
"drop pipePlugin TestProcessor",
771-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
765+
"803: Access Denied: No permissions for this operation, only root user is allowed",
772766
"test",
773767
"test123",
774768
null);
775769
assertTableTestFail(
776770
senderEnv,
777771
"show pipe plugins",
778-
"803: Access Denied: No permissions for this operation, please add privilege MAINTAIN",
772+
"803: Access Denied: No permissions for this operation, only root user is allowed",
779773
"test",
780774
"test123",
781775
null);
782-
783-
grantUserSystemPrivileges(senderEnv, "test", PrivilegeType.MAINTAIN);
784-
785-
executeNonQueryWithRetry(
786-
senderEnv,
787-
"create pipe testPipe\n"
788-
+ "with connector (\n"
789-
+ " 'connector'='write-back-connector'\n"
790-
+ ")",
791-
"test",
792-
"test123",
793-
null,
794-
BaseEnv.TABLE_SQL_DIALECT);
795-
executeQueryWithRetry(
796-
senderEnv, "show pipes", "test", "test123", null, BaseEnv.TABLE_SQL_DIALECT);
797-
executeNonQueriesWithRetry(
798-
senderEnv,
799-
Arrays.asList("start pipe testPipe", "stop pipe testPipe", "drop pipe testPipe"),
800-
"test",
801-
"test123",
802-
null,
803-
BaseEnv.TABLE_SQL_DIALECT);
804-
805-
assertTableNonQueryTestFail(
806-
senderEnv,
807-
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'xxx'",
808-
"701: Untrusted uri xxx",
809-
"test",
810-
"test123",
811-
null);
812-
executeQueryWithRetry(
813-
senderEnv, "show pipe plugins", "test", "test123", null, BaseEnv.TABLE_SQL_DIALECT);
814776
}
815777
}

0 commit comments

Comments
 (0)