feat: adds integration tests for public buckets.

This commit is contained in:
niksis02
2025-06-11 00:55:58 +04:00
parent edaf9d6d4e
commit f877502ab0
2 changed files with 22 additions and 3 deletions
+3 -3
View File
@@ -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)
+19
View File
@@ -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