From acdd2de21f49d61cce14e449312b25be81588d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Fri, 10 Apr 2026 07:07:14 +0800 Subject: [PATCH] refactor(app): inline bucket encryption output (#2452) --- rustfs/src/app/bucket_usecase.rs | 17 ++++++++++++++++- rustfs/src/storage/s3_api/encryption.rs | 14 ++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/rustfs/src/app/bucket_usecase.rs b/rustfs/src/app/bucket_usecase.rs index 73e0f7608..ccbdc3b62 100644 --- a/rustfs/src/app/bucket_usecase.rs +++ b/rustfs/src/app/bucket_usecase.rs @@ -1439,7 +1439,7 @@ impl DefaultBucketUsecase { if let Err(err) = site_replication_bucket_meta_hook(item).await { warn!(bucket = %bucket, error = ?err, "site replication bucket encryption hook failed"); } - Ok(S3Response::new(encryption::build_put_bucket_encryption_output())) + Ok(S3Response::new(PutBucketEncryptionOutput::default())) } #[instrument(level = "debug", skip(self))] @@ -2841,6 +2841,21 @@ mod tests { assert_eq!(err.code(), &S3ErrorCode::InternalError); } + #[tokio::test] + async fn execute_put_bucket_encryption_returns_internal_error_when_store_uninitialized() { + let input = PutBucketEncryptionInput::builder() + .bucket("test-bucket".to_string()) + .server_side_encryption_configuration(ServerSideEncryptionConfiguration::default()) + .build() + .unwrap(); + + let req = build_request(input, Method::PUT); + let usecase = DefaultBucketUsecase::without_context(); + + let err = usecase.execute_put_bucket_encryption(req).await.unwrap_err(); + assert_eq!(err.code(), &S3ErrorCode::InternalError); + } + #[tokio::test] async fn execute_put_public_access_block_returns_internal_error_when_store_uninitialized() { let input = PutPublicAccessBlockInput::builder() diff --git a/rustfs/src/storage/s3_api/encryption.rs b/rustfs/src/storage/s3_api/encryption.rs index af5f4cf37..3892447ac 100644 --- a/rustfs/src/storage/s3_api/encryption.rs +++ b/rustfs/src/storage/s3_api/encryption.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use s3s::dto::{GetBucketEncryptionOutput, PutBucketEncryptionOutput, ServerSideEncryptionConfiguration}; +use s3s::dto::{GetBucketEncryptionOutput, ServerSideEncryptionConfiguration}; pub(crate) fn build_get_bucket_encryption_output( server_side_encryption_configuration: Option, @@ -22,13 +22,9 @@ pub(crate) fn build_get_bucket_encryption_output( } } -pub(crate) fn build_put_bucket_encryption_output() -> PutBucketEncryptionOutput { - PutBucketEncryptionOutput::default() -} - #[cfg(test)] mod tests { - use super::{build_get_bucket_encryption_output, build_put_bucket_encryption_output}; + use super::build_get_bucket_encryption_output; use s3s::dto::ServerSideEncryptionConfiguration; #[test] @@ -38,10 +34,4 @@ mod tests { assert_eq!(output.server_side_encryption_configuration, config); } - - #[test] - fn test_build_put_bucket_encryption_output_is_default() { - let output = build_put_bucket_encryption_output(); - assert_eq!(output, Default::default()); - } }