diff --git a/rustfs/src/app/bucket_usecase.rs b/rustfs/src/app/bucket_usecase.rs index 3126fe4a9..54ae00482 100644 --- a/rustfs/src/app/bucket_usecase.rs +++ b/rustfs/src/app/bucket_usecase.rs @@ -973,7 +973,7 @@ impl DefaultBucketUsecase { warn!(bucket = %bucket, error = ?err, "site replication bucket tagging delete hook failed"); } - Ok(S3Response::new(tagging::build_delete_bucket_tagging_output())) + Ok(S3Response::new(DeleteBucketTaggingOutput {})) } #[instrument(level = "debug", skip(self))] @@ -1788,7 +1788,7 @@ impl DefaultBucketUsecase { warn!(bucket = %bucket, error = ?err, "site replication bucket tagging hook failed"); } - Ok(S3Response::new(tagging::build_put_bucket_tagging_output())) + Ok(S3Response::new(PutBucketTaggingOutput::default())) } #[instrument(level = "debug", skip(self))] @@ -2856,6 +2856,26 @@ mod tests { assert_eq!(err.code(), &S3ErrorCode::InternalError); } + #[tokio::test] + async fn execute_put_bucket_tagging_returns_internal_error_when_store_uninitialized() { + let input = PutBucketTaggingInput::builder() + .bucket("test-bucket".to_string()) + .tagging(Tagging { + tag_set: vec![Tag { + key: Some("env".to_string()), + value: Some("prod".to_string()), + }], + }) + .build() + .unwrap(); + + let req = build_request(input, Method::PUT); + let usecase = DefaultBucketUsecase::without_context(); + + let err = usecase.execute_put_bucket_tagging(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/tagging.rs b/rustfs/src/storage/s3_api/tagging.rs index f36046d6c..1b3cdf2ac 100644 --- a/rustfs/src/storage/s3_api/tagging.rs +++ b/rustfs/src/storage/s3_api/tagging.rs @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use s3s::dto::{ - DeleteBucketTaggingOutput, DeleteObjectTaggingOutput, GetBucketTaggingOutput, GetObjectTaggingOutput, PutBucketTaggingOutput, - PutObjectTaggingOutput, Tag, -}; +use s3s::dto::{DeleteObjectTaggingOutput, GetBucketTaggingOutput, GetObjectTaggingOutput, PutObjectTaggingOutput, Tag}; use s3s::{S3Error, S3ErrorCode, S3Result}; use std::collections::HashSet; @@ -73,23 +70,14 @@ pub(crate) fn build_delete_object_tagging_output(version_id: Option) -> DeleteObjectTaggingOutput { version_id } } -pub(crate) fn build_put_bucket_tagging_output() -> PutBucketTaggingOutput { - PutBucketTaggingOutput::default() -} - -pub(crate) fn build_delete_bucket_tagging_output() -> DeleteBucketTaggingOutput { - DeleteBucketTaggingOutput {} -} - #[cfg(test)] mod tests { use super::{ - build_delete_bucket_tagging_output, build_delete_object_tagging_output, build_get_bucket_tagging_output, - build_get_object_tagging_output, build_put_bucket_tagging_output, build_put_object_tagging_output, - validate_object_tag_set, + build_delete_object_tagging_output, build_get_bucket_tagging_output, build_get_object_tagging_output, + build_put_object_tagging_output, validate_object_tag_set, }; use s3s::S3ErrorCode; - use s3s::dto::{DeleteBucketTaggingOutput, Tag}; + use s3s::dto::Tag; fn tag(key: Option<&str>, value: Option<&str>) -> Tag { Tag { @@ -175,13 +163,4 @@ mod tests { assert_eq!(put_object_output.version_id, Some("vid-1".to_string())); assert_eq!(delete_object_output.version_id, Some("vid-1".to_string())); } - - #[test] - fn test_build_bucket_tagging_outputs_are_default_shape() { - let put_output = build_put_bucket_tagging_output(); - let delete_output = build_delete_bucket_tagging_output(); - - assert_eq!(put_output, Default::default()); - assert_eq!(delete_output, DeleteBucketTaggingOutput {}); - } }