committing new tests (#1879)

This commit is contained in:
adfost
2022-04-28 09:52:37 -07:00
committed by GitHub
parent 415088ae2d
commit c68c175827
3 changed files with 775 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ import (
policyApi "github.com/minio/console/restapi/operations/policy"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
iampolicy "github.com/minio/pkg/iam/policy"
@@ -286,7 +287,23 @@ func getListUsersForPolicyResponse(session *models.Principal, policy string) ([]
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPolicies(ctx, adminClient)
if err != nil {
return nil, prepareError(err)
}
found := false
for i := range policies {
if policies[i].Name == policy {
found = true
}
}
if !found {
return nil, &models.Error{
Code: int32(404),
Message: swag.String("Policy does not exist"),
DetailedMessage: swag.String(fmt.Sprintf("The policy %s does not extist", policy)),
}
}
users, err := listUsers(ctx, adminClient)
if err != nil {
return nil, prepareError(err)
@@ -315,6 +332,23 @@ func getListGroupsForPolicyResponse(session *models.Principal, policy string) ([
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPolicies(ctx, adminClient)
if err != nil {
return nil, prepareError(err)
}
found := false
for i := range policies {
if policies[i].Name == policy {
found = true
}
}
if !found {
return nil, &models.Error{
Code: int32(404),
Message: swag.String("Policy does not exist"),
DetailedMessage: swag.String(fmt.Sprintf("The policy %s does not extist", policy)),
}
}
groups, err := adminClient.listGroups(ctx)
if err != nil {