mirror of
https://github.com/versity/versitygw.git
synced 2026-07-19 22:42:20 +00:00
feat: adds integration tests for public buckets.
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -2186,7 +2185,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
if bodyi != nil {
|
||||
body = bodyi.(io.Reader)
|
||||
} else {
|
||||
body = bytes.NewReader([]byte{})
|
||||
body = ctx.Request().BodyStream()
|
||||
}
|
||||
|
||||
res, err := c.be.UploadPart(ctx.Context(),
|
||||
@@ -2659,7 +2658,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
if bodyi != nil {
|
||||
body = bodyi.(io.Reader)
|
||||
} else {
|
||||
body = bytes.NewReader([]byte{})
|
||||
body = ctx.Request().BodyStream()
|
||||
}
|
||||
|
||||
res, err := c.be.PutObject(ctx.Context(),
|
||||
@@ -3924,6 +3923,7 @@ func SendResponse(ctx *fiber.Ctx, err error, l *MetaOpts) error {
|
||||
ctx.Status(apierr.HTTPStatusCode)
|
||||
return ctx.Send(s3err.GetAPIErrorResponse(apierr, "", "", ""))
|
||||
}
|
||||
fmt.Println(err, "------------")
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Internal Error, %v\n", err)
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
|
||||
@@ -79,6 +79,25 @@ func AuthorizePublicBucketAccess(be backend.Backend, s3action string, policyPerm
|
||||
}
|
||||
}
|
||||
|
||||
if utils.IsBigDataAction(ctx) {
|
||||
payloadType := ctx.Get("X-Amz-Content-Sha256")
|
||||
if utils.IsUnsignedStreamingPayload(payloadType) {
|
||||
checksumType, err := utils.ExtractChecksumType(ctx)
|
||||
if err != nil {
|
||||
return sendResponse(ctx, err, l, mm)
|
||||
}
|
||||
|
||||
wrapBodyReader(ctx, func(r io.Reader) io.Reader {
|
||||
var cr io.Reader
|
||||
cr, err = utils.NewUnsignedChunkReader(r, checksumType)
|
||||
return cr
|
||||
})
|
||||
if err != nil {
|
||||
return sendResponse(ctx, err, l, mm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
utils.ContextKeyPublicBucket.Set(ctx, true)
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user