Skip to content

Commit

Permalink
api: Return correct error on invalid grantee type
Browse files Browse the repository at this point in the history
Closes #908.

Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Feb 8, 2024
1 parent bcc5e23 commit 205f942
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func addGrantees(list []*Grant, headers http.Header, hdr string) ([]*Grant, erro

for _, grantee := range grantees {
if grantee.Type == granteeAmazonCustomerByEmail || (grantee.Type == granteeGroup && grantee.URI != allUsersGroup) {
return nil, stderrors.New("unsupported grantee type")
return nil, s3errors.GetAPIError(s3errors.ErrNotSupported)
}

list = append(list, &Grant{
Expand Down Expand Up @@ -1186,7 +1186,7 @@ func aclToAst(acl *AccessControlPolicy, resInfo *resourceInfo) (*ast, error) {

for _, grant := range acl.AccessControlList {
if grant.Grantee.Type == granteeAmazonCustomerByEmail || (grant.Grantee.Type == granteeGroup && grant.Grantee.URI != allUsersGroup) {
return nil, stderrors.New("unsupported grantee type")
return nil, s3errors.GetAPIError(s3errors.ErrNotSupported)

Check warning on line 1189 in api/handler/acl.go

View check run for this annotation

Codecov / codecov/patch

api/handler/acl.go#L1189

Added line #L1189 was not covered by tests
}

var groupGrantee bool
Expand Down Expand Up @@ -1225,7 +1225,7 @@ func aclToPolicy(acl *AccessControlPolicy, resInfo *resourceInfo) (*bucketPolicy

for _, grant := range acl.AccessControlList {
if grant.Grantee.Type == granteeAmazonCustomerByEmail || (grant.Grantee.Type == granteeGroup && grant.Grantee.URI != allUsersGroup) {
return nil, stderrors.New("unsupported grantee type")
return nil, s3errors.GetAPIError(s3errors.ErrNotSupported)

Check warning on line 1228 in api/handler/acl.go

View check run for this annotation

Codecov / codecov/patch

api/handler/acl.go#L1228

Added line #L1228 was not covered by tests
}

user := grant.Grantee.ID
Expand Down

0 comments on commit 205f942

Please sign in to comment.