This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 89e8a62c9cf [Fix]Fix show role stmt missing grouo info (#36032)
89e8a62c9cf is described below
commit 89e8a62c9cf80ad169bd0d96fbd3f3ef85763ba0
Author: wangbo <[email protected]>
AuthorDate: Tue Jun 11 14:19:28 2024 +0800
[Fix]Fix show role stmt missing grouo info (#36032)
---
.../org/apache/doris/analysis/ShowRolesStmt.java | 1 +
.../apache/doris/mysql/privilege/RoleManager.java | 2 +-
.../org/apache/doris/mysql/privilege/AuthTest.java | 42 ++++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRolesStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRolesStmt.java
index 5131b99497c..bbb66b27443 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRolesStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRolesStmt.java
@@ -44,6 +44,7 @@ public class ShowRolesStmt extends ShowStmt {
builder.addColumn(new Column("CloudClusterPrivs",
ScalarType.createVarchar(300)));
builder.addColumn(new Column("CloudStagePrivs",
ScalarType.createVarchar(300)));
builder.addColumn(new Column("StorageVaultPrivs",
ScalarType.createVarchar(300)));
+ builder.addColumn(new Column("WorkloadGroupPrivs",
ScalarType.createVarchar(300)));
META_DATA = builder.build();
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/RoleManager.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/RoleManager.java
index be86b69a5c3..93bd7f72fdc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/RoleManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/RoleManager.java
@@ -199,7 +199,7 @@ public class RoleManager implements Writable,
GsonPostProcessable {
));
Stream.of(PrivLevel.GLOBAL, PrivLevel.CATALOG, PrivLevel.DATABASE,
PrivLevel.TABLE, PrivLevel.RESOURCE,
- PrivLevel.CLUSTER, PrivLevel.STAGE,
PrivLevel.STORAGE_VAULT)
+ PrivLevel.CLUSTER, PrivLevel.STAGE,
PrivLevel.STORAGE_VAULT, PrivLevel.WORKLOAD_GROUP)
.forEach(level -> {
String infoItem = infoMap.get(level);
if (Strings.isNullOrEmpty(infoItem)) {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/AuthTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/AuthTest.java
index 884c75e2d1d..8f9e46a9394 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/AuthTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/AuthTest.java
@@ -55,6 +55,7 @@ import org.junit.Before;
import org.junit.Test;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -2393,4 +2394,45 @@ public class AuthTest {
Assert.assertTrue(
auth.checkPlainPasswordForTest("root", "192.168.0.1",
"validRootPassword", null));
}
+
+ @Test
+ public void testShowRoles() {
+ String role = "test_wg_role";
+ CreateRoleStmt roleStmt = new CreateRoleStmt(role);
+ try {
+ roleStmt.analyze(analyzer);
+ auth.createRole(roleStmt);
+ } catch (UserException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
+ AccessPrivilege accessPrivilege =
AccessPrivilege.fromName("USAGE_PRIV");
+ AccessPrivilegeWithCols apwc = new
AccessPrivilegeWithCols(accessPrivilege);
+ List<AccessPrivilegeWithCols> list = new ArrayList<>();
+ list.add(apwc);
+ WorkloadGroupPattern wgp = new WorkloadGroupPattern("test_wg");
+ GrantStmt grantStmt = new GrantStmt(null, role, wgp, list);
+ try {
+ grantStmt.analyze(analyzer);
+ auth.grant(grantStmt);
+ } catch (UserException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
+ List<List<String>> showInfo = auth.getRoleInfo();
+ boolean findWgPriv = false;
+ for (int i = 0; i < showInfo.size(); i++) {
+ List<String> row = showInfo.get(i);
+ String name = row.get(0);
+ if (role.equals(name)) {
+ findWgPriv = true;
+ String wgPriv = row.get(row.size() - 1);
+ Assert.assertTrue("test_wg: Usage_priv".equals(wgPriv));
+ }
+ }
+ Assert.assertTrue(findWgPriv);
+
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]