frostfs-s3-gw/api/layer/cors_test.go
Pavel Pogodaev c0c4bdb366
All checks were successful
/ DCO (pull_request) Successful in 36s
/ Vulncheck (pull_request) Successful in 1m10s
/ Builds (pull_request) Successful in 1m38s
/ OCI image (pull_request) Successful in 2m13s
/ Lint (pull_request) Successful in 2m24s
/ Tests (pull_request) Successful in 1m20s
/ Vulncheck (push) Successful in 1m9s
/ Builds (push) Successful in 58s
/ OCI image (push) Successful in 1m58s
/ Lint (push) Successful in 2m5s
/ Tests (push) Successful in 1m15s
[#650] Add Copies Numbers for PostObject operation
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2025-03-14 15:57:05 +03:00

46 lines
1,015 B
Go

package layer
import (
"encoding/xml"
"io"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestCorsCopiesNumber(t *testing.T) {
tc := prepareCORSContext(t)
body := `
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedMethod>GET</AllowedMethod>
<AllowedOrigin>http://www.example.com</AllowedOrigin>
<AllowedHeader>Authorization</AllowedHeader>
<ExposeHeader>x-amz-*</ExposeHeader>
</CORSRule>
</CORSConfiguration>
`
copies := []uint32{2, 0}
err := tc.layer.PutBucketCORS(tc.ctx, &PutCORSParams{
BktInfo: tc.bktInfo,
Reader: strings.NewReader(body),
CopiesNumbers: copies,
UserAgent: "",
NewDecoder: NewXMLDecoder,
})
require.NoError(t, err)
objs := tc.testFrostFS.Objects()
require.Len(t, objs, 1)
require.EqualValues(t, copies, tc.testFrostFS.CopiesNumbers(addrFromObject(objs[0]).EncodeToString()))
}
func NewXMLDecoder(r io.Reader, _ string) *xml.Decoder {
dec := xml.NewDecoder(r)
return dec
}