Skip to content

Commit ecd7d92

Browse files
authored
Pipe: Enabled config audit logger & Fixed some checks of config privilege & keep the tree model show pipes aligned with table model's & Fixed the bug that password with "-" prefix cannot be directly entered in Cli & Fixed some pipe ITs & Added the missing source privilege check for PipeAlterEncodingCompressorPlan (apache#16957)
* fix * permission-change * user_role * part * fix * f * fix * fix * fix * no-excep * pw-args * fix * test * partial * hdx * Update IoTDBConfigNodeReceiver.java * part * fix * refactor * fix * IT-fix * fix-SQL * clean * fix * add-test * fix
1 parent 0110b34 commit ecd7d92

File tree

19 files changed

+1058
-715
lines changed

19 files changed

+1058
-715
lines changed

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeLifeCycleIT.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -833,12 +833,8 @@ public void testPermission() {
833833
"803: No permissions for this operation, please add privilege SYSTEM",
834834
"test",
835835
"test123123456");
836-
assertTestFail(
837-
senderEnv,
838-
"show pipes",
839-
"803: No permissions for this operation, please add privilege SYSTEM",
840-
"test",
841-
"test123123456");
836+
// Will not throw exception
837+
executeQueryWithRetry(senderEnv, "show pipes", "test", "test123123456");
842838
assertNonQueryTestFail(
843839
senderEnv,
844840
"start pipe testPipe",
@@ -866,7 +862,7 @@ public void testPermission() {
866862
"test123123456");
867863
assertTestFail(
868864
senderEnv,
869-
"show pipe plugins",
865+
"show pipePlugins",
870866
"803: No permissions for this operation, please add privilege SYSTEM",
871867
"test",
872868
"test123123456");

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/manual/IoTDBPipePermissionIT.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2323
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
2424
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq;
25-
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeReq;
2625
import org.apache.iotdb.consensus.ConsensusFactory;
2726
import org.apache.iotdb.db.it.utils.TestUtils;
2827
import org.apache.iotdb.it.env.MultiEnvFactory;
@@ -39,6 +38,7 @@
3938
import org.junit.runner.RunWith;
4039

4140
import java.sql.Connection;
41+
import java.sql.ResultSet;
4242
import java.sql.SQLException;
4343
import java.sql.Statement;
4444
import java.util.Arrays;
@@ -360,8 +360,9 @@ public void testSourcePermission() {
360360
TestUtils.executeNonQuery(senderEnv, "create database root.test1");
361361

362362
// Shall be transferred
363+
// The root.test may or may not be transferred due to delayed start of the config source
363364
TestUtils.assertDataEventuallyOnEnv(
364-
receiverEnv, "count databases root.tes*", "count,", Collections.singleton("1,"));
365+
receiverEnv, "count databases root.test1", "count,", Collections.singleton("1,"));
365366

366367
// Alter pipe, throw exception if no privileges
367368
try (final Connection connection = senderEnv.getConnection();
@@ -417,10 +418,12 @@ public void testSourcePermission() {
417418
TestUtils.executeNonQuery(senderEnv, "revoke SYSTEM on root.** from user thulab");
418419

419420
// A user shall only see its own pipe
420-
try (final SyncConfigNodeIServiceClient client =
421-
(SyncConfigNodeIServiceClient) senderEnv.getLeaderConfigNodeConnection()) {
422-
Assert.assertEquals(
423-
1, client.showPipe(new TShowPipeReq().setUserName("thulab")).pipeInfoList.size());
421+
try (final Connection connection = senderEnv.getConnection("thulab", "passwD@123456");
422+
final Statement statement = connection.createStatement()) {
423+
// Will not throw any exception
424+
final ResultSet resultSet = statement.executeQuery("show pipes");
425+
Assert.assertTrue(resultSet.next());
426+
Assert.assertFalse(resultSet.next());
424427
} catch (Exception e) {
425428
fail(e.getMessage());
426429
}

iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ static String[] removePasswordArgs(String[] args) {
321321
}
322322
}
323323
if (index >= 0) {
324-
if (index + 1 >= args.length
325-
|| args[index + 1].startsWith("-")
326-
|| (keywordSet.contains(args[index + 1]))) {
324+
if (index + 1 >= args.length || keywordSet.contains(args[index + 1])) {
327325
return ArrayUtils.remove(args, index);
328326
}
329327
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,23 +1353,6 @@ public TAuthizedPatternTreeResp fetchAuthizedPatternTree(String username, int pe
13531353
}
13541354
}
13551355

1356-
public TPermissionInfoResp checkUserPrivilegeGrantOpt(String username, PrivilegeUnion union) {
1357-
TSStatus status = confirmLeader();
1358-
TPermissionInfoResp resp = new TPermissionInfoResp();
1359-
if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
1360-
try {
1361-
resp = permissionManager.checkUserPrivilegeGrantOpt(username, union);
1362-
} catch (AuthException e) {
1363-
status.setCode(e.getCode().getStatusCode()).setMessage(e.getMessage());
1364-
resp.setStatus(status);
1365-
return resp;
1366-
}
1367-
} else {
1368-
resp.setStatus(status);
1369-
}
1370-
return resp;
1371-
}
1372-
13731356
public TPermissionInfoResp checkRoleOfUser(String username, String rolename) {
13741357
TSStatus status = confirmLeader();
13751358
TPermissionInfoResp resp = new TPermissionInfoResp();

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ public PathPatternTree fetchRawAuthorizedPTree(final String userName, final Priv
134134
return authorInfo.generateRawAuthorizedPTree(userName, type);
135135
}
136136

137-
public TPermissionInfoResp checkUserPrivilegeGrantOpt(String username, PrivilegeUnion union)
138-
throws AuthException {
139-
union.setGrantOption(true);
140-
return authorInfo.checkUserPrivileges(username, union);
141-
}
142-
143137
public TPermissionInfoResp checkRoleOfUser(String username, String rolename)
144138
throws AuthException {
145139
return authorInfo.checkRoleOfUser(username, rolename);

0 commit comments

Comments
 (0)