mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 05:06:28 +00:00
refactor(app): inline bucket tagging outputs (#2455)
This commit is contained in:
@@ -973,7 +973,7 @@ impl DefaultBucketUsecase {
|
|||||||
warn!(bucket = %bucket, error = ?err, "site replication bucket tagging delete hook failed");
|
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))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
@@ -1788,7 +1788,7 @@ impl DefaultBucketUsecase {
|
|||||||
warn!(bucket = %bucket, error = ?err, "site replication bucket tagging hook failed");
|
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))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
@@ -2856,6 +2856,26 @@ mod tests {
|
|||||||
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
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]
|
#[tokio::test]
|
||||||
async fn execute_put_public_access_block_returns_internal_error_when_store_uninitialized() {
|
async fn execute_put_public_access_block_returns_internal_error_when_store_uninitialized() {
|
||||||
let input = PutPublicAccessBlockInput::builder()
|
let input = PutPublicAccessBlockInput::builder()
|
||||||
|
|||||||
@@ -12,10 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use s3s::dto::{
|
use s3s::dto::{DeleteObjectTaggingOutput, GetBucketTaggingOutput, GetObjectTaggingOutput, PutObjectTaggingOutput, Tag};
|
||||||
DeleteBucketTaggingOutput, DeleteObjectTaggingOutput, GetBucketTaggingOutput, GetObjectTaggingOutput, PutBucketTaggingOutput,
|
|
||||||
PutObjectTaggingOutput, Tag,
|
|
||||||
};
|
|
||||||
use s3s::{S3Error, S3ErrorCode, S3Result};
|
use s3s::{S3Error, S3ErrorCode, S3Result};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
@@ -73,23 +70,14 @@ pub(crate) fn build_delete_object_tagging_output(version_id: Option<String>) ->
|
|||||||
DeleteObjectTaggingOutput { version_id }
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
build_delete_bucket_tagging_output, build_delete_object_tagging_output, build_get_bucket_tagging_output,
|
build_delete_object_tagging_output, build_get_bucket_tagging_output, build_get_object_tagging_output,
|
||||||
build_get_object_tagging_output, build_put_bucket_tagging_output, build_put_object_tagging_output,
|
build_put_object_tagging_output, validate_object_tag_set,
|
||||||
validate_object_tag_set,
|
|
||||||
};
|
};
|
||||||
use s3s::S3ErrorCode;
|
use s3s::S3ErrorCode;
|
||||||
use s3s::dto::{DeleteBucketTaggingOutput, Tag};
|
use s3s::dto::Tag;
|
||||||
|
|
||||||
fn tag(key: Option<&str>, value: Option<&str>) -> Tag {
|
fn tag(key: Option<&str>, value: Option<&str>) -> Tag {
|
||||||
Tag {
|
Tag {
|
||||||
@@ -175,13 +163,4 @@ mod tests {
|
|||||||
assert_eq!(put_object_output.version_id, Some("vid-1".to_string()));
|
assert_eq!(put_object_output.version_id, Some("vid-1".to_string()));
|
||||||
assert_eq!(delete_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 {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user