mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Added bucket name param to ToJSONError call (#9961)
when called with InvalidBucketName error. The user is shown a more specific error when the param is present.
This commit is contained in:
parent
968342c732
commit
c00d410e61
@ -166,7 +166,7 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, true) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
opts := BucketOptions{
|
||||
@ -233,7 +233,7 @@ func (web *webAPIHandlers) DeleteBucket(r *http.Request, args *RemoveBucketArgs,
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
reply.UIVersion = browser.UIVersion
|
||||
@ -523,7 +523,7 @@ func (web *webAPIHandlers) ListObjects(r *http.Request, args *ListObjectsArgs, r
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
nextMarker := ""
|
||||
@ -618,7 +618,7 @@ func (web *webAPIHandlers) RemoveObject(r *http.Request, args *RemoveObjectArgs,
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
reply.UIVersion = browser.UIVersion
|
||||
@ -1599,7 +1599,7 @@ func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolic
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
var policyInfo = &miniogopolicy.BucketAccessPolicy{Version: "2012-10-17"}
|
||||
@ -1696,7 +1696,7 @@ func (web *webAPIHandlers) ListAllBucketPolicies(r *http.Request, args *ListAllB
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
var policyInfo = new(miniogopolicy.BucketAccessPolicy)
|
||||
@ -1787,7 +1787,7 @@ func (web *webAPIHandlers) SetBucketPolicy(r *http.Request, args *SetBucketPolic
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
policyType := miniogopolicy.BucketPolicy(args.Policy)
|
||||
@ -1939,7 +1939,7 @@ func (web *webAPIHandlers) PresignedGet(r *http.Request, args *PresignedGetArgs,
|
||||
|
||||
// Check if bucket is a reserved bucket name or invalid.
|
||||
if isReservedOrInvalidBucket(args.BucketName, false) {
|
||||
return toJSONError(ctx, errInvalidBucketName)
|
||||
return toJSONError(ctx, errInvalidBucketName, args.BucketName)
|
||||
}
|
||||
|
||||
// Check if the user indeed has GetObject access,
|
||||
|
@ -329,13 +329,23 @@ func testDeleteBucketWebHandler(obj ObjectLayer, instanceType string, t TestErrH
|
||||
// Empty string = no error
|
||||
expect string
|
||||
}{
|
||||
{"", false, token, "The specified bucket is not valid"},
|
||||
{"", false, token, "Bucket Name is invalid. Lowercase letters, period, " +
|
||||
"hyphen, numerals are the only allowed characters and should be minimum " +
|
||||
"3 characters in length."},
|
||||
{".", false, "auth", "Authentication failed"},
|
||||
{".", false, token, "The specified bucket is not valid"},
|
||||
{"..", false, token, "The specified bucket is not valid"},
|
||||
{"ab", false, token, "The specified bucket is not valid"},
|
||||
{".", false, token, "Bucket Name . is invalid. Lowercase letters, period, " +
|
||||
"hyphen, numerals are the only allowed characters and should be minimum " +
|
||||
"3 characters in length."},
|
||||
{"..", false, token, "Bucket Name .. is invalid. Lowercase letters, period, " +
|
||||
"hyphen, numerals are the only allowed characters and should be minimum " +
|
||||
"3 characters in length."},
|
||||
{"ab", false, token, "Bucket Name ab is invalid. Lowercase letters, period, " +
|
||||
"hyphen, numerals are the only allowed characters and should be minimum " +
|
||||
"3 characters in length."},
|
||||
{"minio", false, "false token", "Authentication failed"},
|
||||
{"minio", false, token, "The specified bucket is not valid"},
|
||||
{"minio", false, token, "Bucket Name minio is invalid. Lowercase letters, period, " +
|
||||
"hyphen, numerals are the only allowed characters and should be minimum " +
|
||||
"3 characters in length."},
|
||||
{bucketName, false, token, ""},
|
||||
{bucketName, true, token, "The bucket you tried to delete is not empty"},
|
||||
{bucketName, false, "", "JWT token missing"},
|
||||
|
Loading…
Reference in New Issue
Block a user