mirror of
https://github.com/versity/versitygw.git
synced 2026-04-20 12:40:30 +00:00
feat: adds not implemented routes for bucket lifecycle configuration actions
Closes #1443 Adds `NotImplemented` routes for bucket lifecycle configuration S3 actions. - `PutBucketLifecycleConfiguration` - `GetBucketLifecycleConfiguration` - `DeleteBucketLifecycle`
This commit is contained in:
@@ -68,6 +68,8 @@ const (
|
||||
GetIntelligentTieringConfigurationAction Action = "s3:GetIntelligentTieringConfiguration"
|
||||
PutInventoryConfigurationAction Action = "s3:PutInventoryConfiguration"
|
||||
GetInventoryConfigurationAction Action = "s3:GetInventoryConfiguration"
|
||||
PutLifecycleConfigurationAction Action = "s3:PutLifecycleConfiguration"
|
||||
GetLifecycleConfigurationAction Action = "s3:GetLifecycleConfiguration"
|
||||
|
||||
AllActions Action = "s3:*"
|
||||
)
|
||||
|
||||
@@ -90,6 +90,9 @@ var (
|
||||
ActionGetBucketInventoryConfiguration = "s3_GetBucketInventoryConfiguration"
|
||||
ActionListBucketInventoryConfigurations = "s3_ListBucketInventoryConfigurations"
|
||||
ActionDeleteBucketInventoryConfiguration = "s3_DeleteBucketInventoryConfiguration"
|
||||
ActionPutBucketLifecycleConfiguration = "s3_PutBucketLifecycleConfiguration"
|
||||
ActionGetBucketLifecycleConfiguration = "s3_GetBucketLifecycleConfiguration"
|
||||
ActionDeleteBucketLifecycle = "s3_DeleteBucketLifecycle"
|
||||
|
||||
// Admin actions
|
||||
ActionAdminCreateUser = "admin_CreateUser"
|
||||
|
||||
@@ -251,6 +251,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
|
||||
middlewares.ParseAcl(be),
|
||||
),
|
||||
)
|
||||
bucketRouter.Put("",
|
||||
middlewares.MatchQueryArgs("lifecycle"),
|
||||
controllers.ProcessHandlers(
|
||||
ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)),
|
||||
metrics.ActionPutBucketLifecycleConfiguration,
|
||||
services,
|
||||
middlewares.BucketObjectNameValidator(),
|
||||
middlewares.AuthorizePublicBucketAccess(be, metrics.ActionPutBucketLifecycleConfiguration, auth.PutLifecycleConfigurationAction, 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,
|
||||
@@ -386,6 +400,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
|
||||
middlewares.ParseAcl(be),
|
||||
),
|
||||
)
|
||||
bucketRouter.Delete("",
|
||||
middlewares.MatchQueryArgs("lifecycle"),
|
||||
controllers.ProcessHandlers(
|
||||
ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)),
|
||||
metrics.ActionDeleteBucketLifecycle,
|
||||
services,
|
||||
middlewares.BucketObjectNameValidator(),
|
||||
middlewares.AuthorizePublicBucketAccess(be, metrics.ActionDeleteBucketLifecycle, auth.PutLifecycleConfigurationAction, auth.PermissionWrite),
|
||||
middlewares.VerifyPresignedV4Signature(root, iam, region, debug),
|
||||
middlewares.VerifyV4Signature(root, iam, region, debug),
|
||||
middlewares.VerifyMD5Body(),
|
||||
middlewares.ParseAcl(be),
|
||||
),
|
||||
)
|
||||
bucketRouter.Delete("",
|
||||
controllers.ProcessHandlers(
|
||||
ctrl.DeleteBucket,
|
||||
@@ -615,6 +643,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
|
||||
middlewares.ParseAcl(be),
|
||||
),
|
||||
)
|
||||
bucketRouter.Get("",
|
||||
middlewares.MatchQueryArgs("lifecycle"),
|
||||
controllers.ProcessHandlers(
|
||||
ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)),
|
||||
metrics.ActionGetBucketLifecycleConfiguration,
|
||||
services,
|
||||
middlewares.BucketObjectNameValidator(),
|
||||
middlewares.AuthorizePublicBucketAccess(be, metrics.ActionGetBucketLifecycleConfiguration, auth.GetLifecycleConfigurationAction, 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(
|
||||
|
||||
@@ -603,6 +603,10 @@ func TestNotImplementedActions(s *S3Conf) {
|
||||
GetBucketInventoryConfiguration_not_implemented(s)
|
||||
ListBucketInventoryConfiguration_not_implemented(s)
|
||||
DeleteBucketInventoryConfiguration_not_implemented(s)
|
||||
// bucket lifecycle configuration actions
|
||||
PutBucketLifecycleConfiguration_not_implemented(s)
|
||||
GetBucketLifecycleConfiguration_not_implemented(s)
|
||||
DeleteBucketLifecycle_not_implemented(s)
|
||||
}
|
||||
|
||||
func TestWORMProtection(s *S3Conf) {
|
||||
@@ -1325,6 +1329,9 @@ func GetIntTests() IntTests {
|
||||
"GetBucketInventoryConfiguration_not_implemented": GetBucketInventoryConfiguration_not_implemented,
|
||||
"ListBucketInventoryConfiguration_not_implemented": ListBucketInventoryConfiguration_not_implemented,
|
||||
"DeleteBucketInventoryConfiguration_not_implemented": DeleteBucketInventoryConfiguration_not_implemented,
|
||||
"PutBucketLifecycleConfiguration_not_implemented": PutBucketLifecycleConfiguration_not_implemented,
|
||||
"GetBucketLifecycleConfiguration_not_implemented": GetBucketLifecycleConfiguration_not_implemented,
|
||||
"DeleteBucketLifecycle_not_implemented": DeleteBucketLifecycle_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,
|
||||
|
||||
@@ -14867,6 +14867,63 @@ func DeleteBucketInventoryConfiguration_not_implemented(s *S3Conf) error {
|
||||
})
|
||||
}
|
||||
|
||||
func PutBucketLifecycleConfiguration_not_implemented(s *S3Conf) error {
|
||||
testName := "PutBucketLifecycleConfiguration_not_implemented"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err := s3client.PutBucketAnalyticsConfiguration(ctx,
|
||||
&s3.PutBucketAnalyticsConfigurationInput{
|
||||
Bucket: &bucket,
|
||||
Id: getPtr("unique_id"),
|
||||
AnalyticsConfiguration: &types.AnalyticsConfiguration{
|
||||
Id: getPtr("my-id"),
|
||||
StorageClassAnalysis: &types.StorageClassAnalysis{
|
||||
DataExport: &types.StorageClassAnalysisDataExport{
|
||||
Destination: &types.AnalyticsExportDestination{
|
||||
S3BucketDestination: &types.AnalyticsS3BucketDestination{
|
||||
Bucket: &bucket,
|
||||
Format: types.AnalyticsS3ExportFileFormatCsv,
|
||||
},
|
||||
},
|
||||
OutputSchemaVersion: types.StorageClassAnalysisSchemaVersionV1,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
cancel()
|
||||
|
||||
return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented))
|
||||
})
|
||||
}
|
||||
|
||||
func GetBucketLifecycleConfiguration_not_implemented(s *S3Conf) error {
|
||||
testName := "GetBucketLifecycleConfiguration_not_implemented"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err := s3client.GetBucketLifecycleConfiguration(ctx,
|
||||
&s3.GetBucketLifecycleConfigurationInput{
|
||||
Bucket: &bucket,
|
||||
})
|
||||
cancel()
|
||||
|
||||
return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented))
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteBucketLifecycle_not_implemented(s *S3Conf) error {
|
||||
testName := "DeleteBucketLifecycle_not_implemented"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err := s3client.DeleteBucketLifecycle(ctx,
|
||||
&s3.DeleteBucketLifecycleInput{
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user