@@ -1230,6 +1230,10 @@ func TestMethodGet(t *testing.T) {
1230
1230
Status : & StatusSuccess ,
1231
1231
Alias : DefaultAliasName ,
1232
1232
}, nil ).Once ()
1233
+ mp .EXPECT ().ListPrivilegeGroups (mock .Anything , mock .Anything ).Return (& milvuspb.ListPrivilegeGroupsResponse {
1234
+ Status : & StatusSuccess ,
1235
+ PrivilegeGroups : []* milvuspb.PrivilegeGroupInfo {{GroupName : "group1" , Privileges : []* milvuspb.PrivilegeEntity {{Name : "*" }}}},
1236
+ }, nil ).Once ()
1233
1237
1234
1238
testEngine := initHTTPServerV2 (mp , false )
1235
1239
queryTestCases := []rawTestCase {}
@@ -1320,6 +1324,9 @@ func TestMethodGet(t *testing.T) {
1320
1324
queryTestCases = append (queryTestCases , rawTestCase {
1321
1325
path : versionalV2 (AliasCategory , DescribeAction ),
1322
1326
})
1327
+ queryTestCases = append (queryTestCases , rawTestCase {
1328
+ path : versionalV2 (PrivilegeGroupCategory , ListAction ),
1329
+ })
1323
1330
1324
1331
for _ , testcase := range queryTestCases {
1325
1332
t .Run (testcase .path , func (t * testing.T ) {
@@ -1329,7 +1336,8 @@ func TestMethodGet(t *testing.T) {
1329
1336
`"indexName": "` + DefaultIndexName + `",` +
1330
1337
`"userName": "` + util .UserRoot + `",` +
1331
1338
`"roleName": "` + util .RoleAdmin + `",` +
1332
- `"aliasName": "` + DefaultAliasName + `"` +
1339
+ `"aliasName": "` + DefaultAliasName + `",` +
1340
+ `"privilegeGroupName": "pg"` +
1333
1341
`}` ))
1334
1342
req := httptest .NewRequest (http .MethodPost , testcase .path , bodyReader )
1335
1343
w := httptest .NewRecorder ()
@@ -1369,6 +1377,7 @@ func TestMethodDelete(t *testing.T) {
1369
1377
mp .EXPECT ().DropRole (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1370
1378
mp .EXPECT ().DropIndex (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1371
1379
mp .EXPECT ().DropAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1380
+ mp .EXPECT ().DropPrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1372
1381
testEngine := initHTTPServerV2 (mp , false )
1373
1382
queryTestCases := []rawTestCase {}
1374
1383
queryTestCases = append (queryTestCases , rawTestCase {
@@ -1389,10 +1398,13 @@ func TestMethodDelete(t *testing.T) {
1389
1398
queryTestCases = append (queryTestCases , rawTestCase {
1390
1399
path : versionalV2 (AliasCategory , DropAction ),
1391
1400
})
1401
+ queryTestCases = append (queryTestCases , rawTestCase {
1402
+ path : versionalV2 (PrivilegeGroupCategory , DropAction ),
1403
+ })
1392
1404
for _ , testcase := range queryTestCases {
1393
1405
t .Run (testcase .path , func (t * testing.T ) {
1394
1406
bodyReader := bytes .NewReader ([]byte (`{"collectionName": "` + DefaultCollectionName + `", "partitionName": "` + DefaultPartitionName +
1395
- `", "userName": "` + util .UserRoot + `", "roleName": "` + util .RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `"}` ))
1407
+ `", "userName": "` + util .UserRoot + `", "roleName": "` + util .RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `", "privilegeGroupName": "pg" }` ))
1396
1408
req := httptest .NewRequest (http .MethodPost , testcase .path , bodyReader )
1397
1409
w := httptest .NewRecorder ()
1398
1410
testEngine .ServeHTTP (w , req )
@@ -1431,6 +1443,8 @@ func TestMethodPost(t *testing.T) {
1431
1443
mp .EXPECT ().CreateIndex (mock .Anything , mock .Anything ).Return (commonErrorStatus , nil ).Once ()
1432
1444
mp .EXPECT ().CreateAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1433
1445
mp .EXPECT ().AlterAlias (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1446
+ mp .EXPECT ().CreatePrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Once ()
1447
+ mp .EXPECT ().OperatePrivilegeGroup (mock .Anything , mock .Anything ).Return (commonSuccessStatus , nil ).Twice ()
1434
1448
mp .EXPECT ().ImportV2 (mock .Anything , mock .Anything ).Return (& internalpb.ImportResponse {
1435
1449
Status : commonSuccessStatus , JobID : "1234567890" ,
1436
1450
}, nil ).Once ()
@@ -1523,6 +1537,15 @@ func TestMethodPost(t *testing.T) {
1523
1537
queryTestCases = append (queryTestCases , rawTestCase {
1524
1538
path : versionalV2 (ImportJobCategory , DescribeAction ),
1525
1539
})
1540
+ queryTestCases = append (queryTestCases , rawTestCase {
1541
+ path : versionalV2 (PrivilegeGroupCategory , CreateAction ),
1542
+ })
1543
+ queryTestCases = append (queryTestCases , rawTestCase {
1544
+ path : versionalV2 (PrivilegeGroupCategory , AddPrivilegesToGroupAction ),
1545
+ })
1546
+ queryTestCases = append (queryTestCases , rawTestCase {
1547
+ path : versionalV2 (PrivilegeGroupCategory , RemovePrivilegesFromGroupAction ),
1548
+ })
1526
1549
1527
1550
for _ , testcase := range queryTestCases {
1528
1551
t .Run (testcase .path , func (t * testing.T ) {
@@ -1533,6 +1556,7 @@ func TestMethodPost(t *testing.T) {
1533
1556
`"indexParams": [{"indexName": "` + DefaultIndexName + `", "fieldName": "book_intro", "metricType": "L2", "params": {"nlist": 30, "index_type": "IVF_FLAT"}}],` +
1534
1557
`"userName": "` + util .UserRoot + `", "password": "Milvus", "newPassword": "milvus", "roleName": "` + util .RoleAdmin + `",` +
1535
1558
`"roleName": "` + util .RoleAdmin + `", "objectType": "Global", "objectName": "*", "privilege": "*",` +
1559
+ `"privilegeGroupName": "pg", "privileges": ["create", "drop"],` +
1536
1560
`"aliasName": "` + DefaultAliasName + `",` +
1537
1561
`"jobId": "1234567890",` +
1538
1562
`"files": [["book.json"]]` +
0 commit comments