diff --git a/src/main/java/io/milvus/v2/service/rbac/RBACService.java b/src/main/java/io/milvus/v2/service/rbac/RBACService.java index c14b33072..48aa32189 100644 --- a/src/main/java/io/milvus/v2/service/rbac/RBACService.java +++ b/src/main/java/io/milvus/v2/service/rbac/RBACService.java @@ -254,7 +254,7 @@ public ListPrivilegeGroupsResp listPrivilegeGroups(MilvusServiceGrpc.MilvusServi privilegeGroupInfo.getPrivilegesList().forEach((privilege)->{ privileges.add(privilege.getName()); }); - privilegeGroups.add(PrivilegeGroup.builder().privileges(privileges).build()); + privilegeGroups.add(PrivilegeGroup.builder().groupName(privilegeGroupInfo.getGroupName()).privileges(privileges).build()); }); return ListPrivilegeGroupsResp.builder() diff --git a/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java b/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java index 39e03cafa..d75140630 100644 --- a/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java +++ b/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java @@ -44,6 +44,9 @@ import io.milvus.v2.service.index.request.*; import io.milvus.v2.service.index.response.*; import io.milvus.v2.service.partition.request.*; +import io.milvus.v2.service.rbac.PrivilegeGroup; +import io.milvus.v2.service.rbac.request.*; +import io.milvus.v2.service.rbac.response.*; import io.milvus.v2.service.utility.request.*; import io.milvus.v2.service.utility.response.*; import io.milvus.v2.service.vector.request.*; @@ -2036,4 +2039,25 @@ void testDynamicField() { Assertions.assertTrue(r.getEntity().containsKey("dynamic_10")); Assertions.assertEquals("this is dynamic value", r.getEntity().get("dynamic_10")); } + + @Test + void testRBAC() { + client.createPrivilegeGroup(CreatePrivilegeGroupReq.builder() + .groupName("dummy") + .build()); + client.addPrivilegesToGroup(AddPrivilegesToGroupReq.builder() + .groupName("dummy") + .privileges(Collections.singletonList("CreateCollection")) + .build()); + + ListPrivilegeGroupsResp resp = client.listPrivilegeGroups(ListPrivilegeGroupsReq.builder().build()); + List groups = resp.getPrivilegeGroups(); + Map> groupsPlivileges = new HashMap<>(); + for (PrivilegeGroup group : groups) { + groupsPlivileges.put(group.getGroupName(), group.getPrivileges()); + } + Assertions.assertTrue(groupsPlivileges.containsKey("dummy")); + Assertions.assertEquals(1, groupsPlivileges.get("dummy").size()); + Assertions.assertEquals("CreateCollection", groupsPlivileges.get("dummy").get(0)); + } }