[#117] Add mocked handler for tests
All checks were successful
/ DCO (pull_request) Successful in 1m22s
/ Builds (1.21) (pull_request) Successful in 1m58s
/ Builds (1.22) (pull_request) Successful in 1m53s
/ Vulncheck (pull_request) Successful in 3m32s
/ Lint (pull_request) Successful in 5m1s
/ Tests (1.21) (pull_request) Successful in 2m38s
/ Tests (1.22) (pull_request) Successful in 3m4s
All checks were successful
/ DCO (pull_request) Successful in 1m22s
/ Builds (1.21) (pull_request) Successful in 1m58s
/ Builds (1.22) (pull_request) Successful in 1m53s
/ Vulncheck (pull_request) Successful in 3m32s
/ Lint (pull_request) Successful in 5m1s
/ Tests (1.21) (pull_request) Successful in 2m38s
/ Tests (1.22) (pull_request) Successful in 3m4s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
826dd0cdbe
commit
3741e3b003
12 changed files with 1005 additions and 113 deletions
|
@ -14,7 +14,6 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/utils"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
||||
"github.com/valyala/fasthttp"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -56,13 +55,16 @@ func (h *Handler) receiveFile(ctx context.Context, req request, objectAddress oi
|
|||
filename string
|
||||
)
|
||||
|
||||
var prm pool.PrmObjectGet
|
||||
prm.SetAddress(objectAddress)
|
||||
if btoken := bearerToken(ctx); btoken != nil {
|
||||
prm.UseBearer(*btoken)
|
||||
prm := PrmObjectRead{
|
||||
PrmAuth: PrmAuth{
|
||||
BearerToken: bearerToken(ctx),
|
||||
},
|
||||
Address: objectAddress,
|
||||
WithHeader: true,
|
||||
WithPayload: true,
|
||||
}
|
||||
|
||||
rObj, err := h.pool.GetObject(ctx, prm)
|
||||
rObj, err := h.frostfs.ReadObject(ctx, prm)
|
||||
if err != nil {
|
||||
req.handleFrostFSErr(err, start)
|
||||
return
|
||||
|
@ -74,11 +76,11 @@ func (h *Handler) receiveFile(ctx context.Context, req request, objectAddress oi
|
|||
dis = "attachment"
|
||||
}
|
||||
|
||||
payloadSize := rObj.Header.PayloadSize()
|
||||
payloadSize := rObj.Head.PayloadSize()
|
||||
|
||||
req.Response.Header.Set(fasthttp.HeaderContentLength, strconv.FormatUint(payloadSize, 10))
|
||||
var contentType string
|
||||
for _, attr := range rObj.Header.Attributes() {
|
||||
for _, attr := range rObj.Head.Attributes() {
|
||||
key := attr.Key()
|
||||
val := attr.Value()
|
||||
if !isValidToken(key) || !isValidValue(val) {
|
||||
|
@ -107,7 +109,7 @@ func (h *Handler) receiveFile(ctx context.Context, req request, objectAddress oi
|
|||
}
|
||||
}
|
||||
|
||||
idsToResponse(&req.Response, &rObj.Header)
|
||||
idsToResponse(&req.Response, rObj.Head)
|
||||
|
||||
if len(contentType) == 0 {
|
||||
// determine the Content-Type from the payload head
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue