From 6b450a5c11c99915a6329ec5b2f4f6bfc57723a6 Mon Sep 17 00:00:00 2001 From: niksis02 Date: Thu, 21 Aug 2025 00:54:31 +0400 Subject: [PATCH] feat: adds not implemented routes for bucket request payment actions Closes #1455 Adds `NotImplemented` routes for bucket request payment S3 actions: - `PutBucketRequestPayment` - `GetBucketRequestPayment` --- auth/bucket_policy_actions.go | 2 ++ metrics/actions.go | 2 ++ s3api/router.go | 28 ++++++++++++++++++++++++++++ tests/integration/group-tests.go | 5 +++++ tests/integration/tests.go | 31 +++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+) diff --git a/auth/bucket_policy_actions.go b/auth/bucket_policy_actions.go index a50d4a4a..96cfb4a5 100644 --- a/auth/bucket_policy_actions.go +++ b/auth/bucket_policy_actions.go @@ -72,6 +72,8 @@ const ( GetLifecycleConfigurationAction Action = "s3:GetLifecycleConfiguration" PutBucketLoggingAction Action = "s3:PutBucketLogging" GetBucketLoggingAction Action = "s3:GetBucketLogging" + PutBucketRequestPaymentAction Action = "s3:PutBucketRequestPayment" + GetBucketRequestPaymentAction Action = "s3:GetBucketRequestPayment" AllActions Action = "s3:*" ) diff --git a/metrics/actions.go b/metrics/actions.go index 971100dd..cef48a81 100644 --- a/metrics/actions.go +++ b/metrics/actions.go @@ -95,6 +95,8 @@ var ( ActionDeleteBucketLifecycle = "s3_DeleteBucketLifecycle" ActionPutBucketLogging = "s3_PutBucketLogging" ActionGetBucketLogging = "s3_GetBucketLogging" + ActionPutBucketRequestPayment = "s3_PutBucketRequestPayment" + ActionGetBucketRequestPayment = "s3_GetBucketRequestPayment" // Admin actions ActionAdminCreateUser = "admin_CreateUser" diff --git a/s3api/router.go b/s3api/router.go index c2e4f514..6396f501 100644 --- a/s3api/router.go +++ b/s3api/router.go @@ -279,6 +279,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ middlewares.ParseAcl(be), ), ) + bucketRouter.Put("", + middlewares.MatchQueryArgs("requestPayment"), + controllers.ProcessHandlers( + ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)), + metrics.ActionPutBucketRequestPayment, + services, + middlewares.BucketObjectNameValidator(), + middlewares.AuthorizePublicBucketAccess(be, metrics.ActionPutBucketRequestPayment, auth.PutBucketRequestPaymentAction, auth.PermissionWrite), + middlewares.VerifyPresignedV4Signature(root, iam, region, debug), + middlewares.VerifyV4Signature(root, iam, region, debug), + middlewares.VerifyMD5Body(), + middlewares.ParseAcl(be), + ), + ) bucketRouter.Put("", controllers.ProcessHandlers( ctrl.CreateBucket, @@ -685,6 +699,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ middlewares.ParseAcl(be), ), ) + bucketRouter.Get("", + middlewares.MatchQueryArgs("requestPayment"), + controllers.ProcessHandlers( + ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)), + metrics.ActionGetBucketRequestPayment, + services, + middlewares.BucketObjectNameValidator(), + middlewares.AuthorizePublicBucketAccess(be, metrics.ActionGetBucketRequestPayment, auth.GetBucketRequestPaymentAction, auth.PermissionRead), + middlewares.VerifyPresignedV4Signature(root, iam, region, debug), + middlewares.VerifyV4Signature(root, iam, region, debug), + middlewares.VerifyMD5Body(), + middlewares.ParseAcl(be), + ), + ) bucketRouter.Get("", middlewares.MatchQueryArgWithValue("list-type", "2"), controllers.ProcessHandlers( diff --git a/tests/integration/group-tests.go b/tests/integration/group-tests.go index 209b6303..e0f0243f 100644 --- a/tests/integration/group-tests.go +++ b/tests/integration/group-tests.go @@ -610,6 +610,9 @@ func TestNotImplementedActions(s *S3Conf) { // bucket logging actions PutBucketLogging_not_implemented(s) GetBucketLogging_not_implemented(s) + // request payment actions + PutBucketRequestPayment_not_implemented(s) + GetBucketRequestPayment_not_implemented(s) } func TestWORMProtection(s *S3Conf) { @@ -1337,6 +1340,8 @@ func GetIntTests() IntTests { "DeleteBucketLifecycle_not_implemented": DeleteBucketLifecycle_not_implemented, "PutBucketLogging_not_implemented": PutBucketLogging_not_implemented, "GetBucketLogging_not_implemented": GetBucketLogging_not_implemented, + "PutBucketRequestPayment_not_implemented": PutBucketRequestPayment_not_implemented, + "GetBucketRequestPayment_not_implemented": GetBucketRequestPayment_not_implemented, "WORMProtection_bucket_object_lock_configuration_compliance_mode": WORMProtection_bucket_object_lock_configuration_compliance_mode, "WORMProtection_bucket_object_lock_configuration_governance_mode": WORMProtection_bucket_object_lock_configuration_governance_mode, "WORMProtection_bucket_object_lock_governance_bypass_delete": WORMProtection_bucket_object_lock_governance_bypass_delete, diff --git a/tests/integration/tests.go b/tests/integration/tests.go index dbaacaea..51d0dc35 100644 --- a/tests/integration/tests.go +++ b/tests/integration/tests.go @@ -14970,6 +14970,37 @@ func GetBucketLogging_not_implemented(s *S3Conf) error { }) } +func PutBucketRequestPayment_not_implemented(s *S3Conf) error { + testName := "PutBucketRequestPayment_not_implemented" + return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + _, err := s3client.PutBucketRequestPayment(ctx, + &s3.PutBucketRequestPaymentInput{ + Bucket: &bucket, + RequestPaymentConfiguration: &types.RequestPaymentConfiguration{ + Payer: types.PayerBucketOwner, + }, + }) + cancel() + + return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented)) + }) +} + +func GetBucketRequestPayment_not_implemented(s *S3Conf) error { + testName := "GetBucketRequestPayment_not_implemented" + return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + _, err := s3client.GetBucketRequestPayment(ctx, + &s3.GetBucketRequestPaymentInput{ + Bucket: &bucket, + }) + cancel() + + return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented)) + }) +} + func WORMProtection_bucket_object_lock_configuration_compliance_mode(s *S3Conf) error { testName := "WORMProtection_bucket_object_lock_configuration_compliance_mode" return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {