mirror of
https://github.com/versity/versitygw.git
synced 2026-04-25 07:00:31 +00:00
fix: Changes the PutBucketTagging action response status code from 200(OK) to 204(No Content)
This commit is contained in:
@@ -1150,6 +1150,7 @@ func (c S3ApiController) PutBucketActions(ctx *fiber.Ctx) error {
|
||||
MetricsMng: c.mm,
|
||||
Action: metrics.ActionPutBucketTagging,
|
||||
BucketOwner: parsedAcl.Owner,
|
||||
Status: http.StatusNoContent,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -750,7 +750,7 @@ func TestS3ApiController_PutBucketActions(t *testing.T) {
|
||||
req: httptest.NewRequest(http.MethodPut, "/my-bucket?tagging", strings.NewReader(tagBody)),
|
||||
},
|
||||
wantErr: false,
|
||||
statusCode: 200,
|
||||
statusCode: 204,
|
||||
},
|
||||
{
|
||||
name: "Put-bucket-ownership-controls-invalid-ownership",
|
||||
|
||||
@@ -116,6 +116,7 @@ func TestPutBucketTagging(s *S3Conf) {
|
||||
PutBucketTagging_non_existing_bucket(s)
|
||||
PutBucketTagging_long_tags(s)
|
||||
PutBucketTagging_success(s)
|
||||
PutBucketTagging_success_status(s)
|
||||
}
|
||||
|
||||
func TestGetBucketTagging(s *S3Conf) {
|
||||
@@ -703,6 +704,7 @@ func GetIntTests() IntTests {
|
||||
"PutBucketTagging_non_existing_bucket": PutBucketTagging_non_existing_bucket,
|
||||
"PutBucketTagging_long_tags": PutBucketTagging_long_tags,
|
||||
"PutBucketTagging_success": PutBucketTagging_success,
|
||||
"PutBucketTagging_success_status": PutBucketTagging_success_status,
|
||||
"GetBucketTagging_non_existing_bucket": GetBucketTagging_non_existing_bucket,
|
||||
"GetBucketTagging_unset_tags": GetBucketTagging_unset_tags,
|
||||
"GetBucketTagging_success": GetBucketTagging_success,
|
||||
|
||||
@@ -2672,6 +2672,45 @@ func PutBucketTagging_success(s *S3Conf) error {
|
||||
})
|
||||
}
|
||||
|
||||
func PutBucketTagging_success_status(s *S3Conf) error {
|
||||
testName := "PutBucketTagging_success_status"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
tagging := types.Tagging{
|
||||
TagSet: []types.Tag{
|
||||
{
|
||||
Key: getPtr("key"),
|
||||
Value: getPtr("val"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
taggingParsed, err := xml.Marshal(tagging)
|
||||
if err != nil {
|
||||
return fmt.Errorf("err parsing tagging: %w", err)
|
||||
}
|
||||
|
||||
req, err := createSignedReq(http.MethodPut, s.endpoint, fmt.Sprintf("%v?tagging=", bucket), s.awsID, s.awsSecret, "s3", s.awsRegion, taggingParsed, time.Now(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("err signing the request: %w", err)
|
||||
}
|
||||
|
||||
client := http.Client{
|
||||
Timeout: shortTimeout,
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("err sending request: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusNoContent {
|
||||
return fmt.Errorf("expected the response status code to be %v, instad got %v", http.StatusNoContent, resp.StatusCode)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func GetBucketTagging_non_existing_bucket(s *S3Conf) error {
|
||||
testName := "GetBucketTagging_non_existing_object"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
|
||||
Reference in New Issue
Block a user