committing new tests (#1879)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user