@@ -897,6 +897,10 @@ func TestMethodGet(t *testing.T) {
897
897
Status : & StatusSuccess ,
898
898
Alias : DefaultAliasName ,
899
899
}, nil ).Once ()
900
+ mp .EXPECT ().ListPrivilegeGroups (mock .Anything , mock .Anything ).Return (& milvuspb.ListPrivilegeGroupsResponse {
901
+ Status : & StatusSuccess ,
902
+ PrivilegeGroups : []* milvuspb.PrivilegeGroupInfo {{GroupName : "group1" , Privileges : []* milvuspb.PrivilegeEntity {{Name : "*" }}}},
903
+ }, nil ).Once ()
900
904
901
905
testEngine := initHTTPServerV2 (mp , false )
902
906
queryTestCases := []rawTestCase {}
@@ -987,6 +991,9 @@ func TestMethodGet(t *testing.T) {
987
991
queryTestCases = append (queryTestCases , rawTestCase {
988
992
path : versionalV2 (AliasCategory , DescribeAction ),
989
993
})
994
+ queryTestCases = append (queryTestCases , rawTestCase {
995
+ path : versionalV2 (PrivilegeGroupCategory , ListAction ),
996
+ })
990
997
991
998
for _ , testcase := range queryTestCases {
992
999
t .Run (testcase .path , func (t * testing.T ) {
@@ -996,7 +1003,8 @@ func TestMethodGet(t *testing.T) {
996
1003
`"indexName": "` + DefaultIndexName + `",` +
997
1004
`"userName": "` + util .UserRoot + `",` +
998
1005
`"roleName": "` + util .RoleAdmin + `",` +
999
- `"aliasName": "` + DefaultAliasName + `"` +
1006
+ `"aliasName": "` + DefaultAliasName + `",` +
1007
+ `"privilegeGroupName": "pg"` +
1000
1008
`}` ))
1001
1009
req := httptest .NewRequest (http .MethodPost , testcase .path , bodyReader )
1002
1010
w := httptest .NewRecorder ()
@@ -1037,6 +1045,7 @@ func TestMethodDelete(t *testing.T) {
1037
1045
mp .EXPECT ().DropRole (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1038
1046
mp .EXPECT ().DropIndex (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1039
1047
mp .EXPECT ().DropAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1048
+ mp .EXPECT ().DropPrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1040
1049
testEngine := initHTTPServerV2 (mp , false )
1041
1050
queryTestCases := []rawTestCase {}
1042
1051
queryTestCases = append (queryTestCases , rawTestCase {
@@ -1057,10 +1066,13 @@ func TestMethodDelete(t *testing.T) {
1057
1066
queryTestCases = append (queryTestCases , rawTestCase {
1058
1067
path : versionalV2 (AliasCategory , DropAction ),
1059
1068
})
1069
+ queryTestCases = append (queryTestCases , rawTestCase {
1070
+ path : versionalV2 (PrivilegeGroupCategory , DropAction ),
1071
+ })
1060
1072
for _ , testcase := range queryTestCases {
1061
1073
t .Run (testcase .path , func (t * testing.T ) {
1062
1074
bodyReader := bytes .NewReader ([]byte (`{"collectionName": "` + DefaultCollectionName + `", "partitionName": "` + DefaultPartitionName +
1063
- `", "userName": "` + util .UserRoot + `", "roleName": "` + util .RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `"}` ))
1075
+ `", "userName": "` + util .UserRoot + `", "roleName": "` + util .RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `", "privilegeGroupName": "pg" }` ))
1064
1076
req := httptest .NewRequest (http .MethodPost , testcase .path , bodyReader )
1065
1077
w := httptest .NewRecorder ()
1066
1078
testEngine .ServeHTTP (w , req )
@@ -1099,6 +1111,8 @@ func TestMethodPost(t *testing.T) {
1099
1111
mp .EXPECT ().CreateIndex (mock .Anything , mock .Anything ).Return (commonErrorStatus , nil ).Once ()
1100
1112
mp .EXPECT ().CreateAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1101
1113
mp .EXPECT ().AlterAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1114
+ mp .EXPECT ().CreatePrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1115
+ mp .EXPECT ().OperatePrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Twice ()
1102
1116
mp .EXPECT ().ImportV2 (mock .Anything , mock .Anything ).Return (& internalpb.ImportResponse {
1103
1117
Status : commonSuccessStatus , JobID : "1234567890" ,
1104
1118
}, nil ).Once ()
@@ -1191,6 +1205,15 @@ func TestMethodPost(t *testing.T) {
1191
1205
queryTestCases = append (queryTestCases , rawTestCase {
1192
1206
path : versionalV2 (ImportJobCategory , DescribeAction ),
1193
1207
})
1208
+ queryTestCases = append (queryTestCases , rawTestCase {
1209
+ path : versionalV2 (PrivilegeGroupCategory , CreateAction ),
1210
+ })
1211
+ queryTestCases = append (queryTestCases , rawTestCase {
1212
+ path : versionalV2 (PrivilegeGroupCategory , AddPrivilegesToGroupAction ),
1213
+ })
1214
+ queryTestCases = append (queryTestCases , rawTestCase {
1215
+ path : versionalV2 (PrivilegeGroupCategory , RemovePrivilegesFromGroupAction ),
1216
+ })
1194
1217
1195
1218
for _ , testcase := range queryTestCases {
1196
1219
t .Run (testcase .path , func (t * testing.T ) {
@@ -1201,6 +1224,7 @@ func TestMethodPost(t *testing.T) {
1201
1224
`"indexParams": [{"indexName": "` + DefaultIndexName + `", "fieldName": "book_intro", "metricType": "L2", "params": {"nlist": 30, "index_type": "IVF_FLAT"}}],` +
1202
1225
`"userName": "` + util .UserRoot + `", "password": "Milvus", "newPassword": "milvus", "roleName": "` + util .RoleAdmin + `",` +
1203
1226
`"roleName": "` + util .RoleAdmin + `", "objectType": "Global", "objectName": "*", "privilege": "*",` +
1227
+ `"privilegeGroupName": "pg", "privileges": ["create", "drop"],` +
1204
1228
`"aliasName": "` + DefaultAliasName + `",` +
1205
1229
`"jobId": "1234567890",` +
1206
1230
`"files": [["book.json"]]` +
0 commit comments