Skip to content

Commit a60c025

Browse files
committed
fix
1 parent eee5ebe commit a60c025

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/source/PipeConfigTreePrivilegeParseVisitorTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.iotdb.commons.exception.MetadataException;
2626
import org.apache.iotdb.commons.utils.StatusUtils;
2727
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
28+
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorTreePlan;
2829
import org.apache.iotdb.confignode.consensus.request.write.database.DatabaseSchemaPlan;
2930
import org.apache.iotdb.confignode.manager.ConfigManager;
3031
import org.apache.iotdb.confignode.manager.PermissionManager;
@@ -96,6 +97,49 @@ ConfigPhysicalPlanType.CreateDatabase, new TDatabaseSchema("root.db1")),
9697
Assert.assertTrue(skipVisitor.canReadSysSchema("root.db", null, false));
9798
}
9899

100+
@Test
101+
public void testAuthPrivilege() {
102+
permissionManager.setUserPrivilege(
103+
(userName, privilegeUnion) ->
104+
privilegeUnion.getPrivilegeType() == PrivilegeType.MANAGE_USER);
105+
Assert.assertTrue(
106+
skipVisitor
107+
.visitGrantUser(new AuthorTreePlan(ConfigPhysicalPlanType.GrantUser), null)
108+
.isPresent());
109+
Assert.assertTrue(
110+
skipVisitor
111+
.visitRevokeUser(new AuthorTreePlan(ConfigPhysicalPlanType.RevokeUser), null)
112+
.isPresent());
113+
Assert.assertFalse(
114+
skipVisitor
115+
.visitGrantRole(new AuthorTreePlan(ConfigPhysicalPlanType.GrantRole), null)
116+
.isPresent());
117+
Assert.assertFalse(
118+
skipVisitor
119+
.visitRevokeRole(new AuthorTreePlan(ConfigPhysicalPlanType.RevokeRole), null)
120+
.isPresent());
121+
122+
permissionManager.setUserPrivilege(
123+
(userName, privilegeUnion) ->
124+
privilegeUnion.getPrivilegeType() == PrivilegeType.MANAGE_ROLE);
125+
Assert.assertFalse(
126+
skipVisitor
127+
.visitGrantUser(new AuthorTreePlan(ConfigPhysicalPlanType.GrantUser), null)
128+
.isPresent());
129+
Assert.assertFalse(
130+
skipVisitor
131+
.visitRevokeUser(new AuthorTreePlan(ConfigPhysicalPlanType.RevokeUser), null)
132+
.isPresent());
133+
Assert.assertTrue(
134+
skipVisitor
135+
.visitGrantRole(new AuthorTreePlan(ConfigPhysicalPlanType.GrantRole), null)
136+
.isPresent());
137+
Assert.assertTrue(
138+
skipVisitor
139+
.visitRevokeRole(new AuthorTreePlan(ConfigPhysicalPlanType.RevokeRole), null)
140+
.isPresent());
141+
}
142+
99143
private static class TestPermissionManager extends PermissionManager {
100144

101145
private BiFunction<String, PrivilegeUnion, Boolean> checkUserPrivileges =

0 commit comments

Comments
 (0)