mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-21 11:56:38 +00:00
refactor(app): inline remaining tagging outputs (#2461)
This commit is contained in:
@@ -23,12 +23,12 @@ use crate::error::ApiError;
|
|||||||
use crate::server::RemoteAddr;
|
use crate::server::RemoteAddr;
|
||||||
use crate::storage::access::{ReqInfo, authorize_request, req_info_ref};
|
use crate::storage::access::{ReqInfo, authorize_request, req_info_ref};
|
||||||
use crate::storage::helper::{OperationHelper, spawn_background_with_context};
|
use crate::storage::helper::{OperationHelper, spawn_background_with_context};
|
||||||
|
use crate::storage::s3_api::acl;
|
||||||
use crate::storage::s3_api::bucket::{
|
use crate::storage::s3_api::bucket::{
|
||||||
ListObjectVersionsParams, ListObjectsV2Params, build_list_buckets_output, build_list_object_versions_output,
|
ListObjectVersionsParams, ListObjectsV2Params, build_list_buckets_output, build_list_object_versions_output,
|
||||||
build_list_objects_v2_output, parse_list_object_versions_params, parse_list_objects_v2_params,
|
build_list_objects_v2_output, parse_list_object_versions_params, parse_list_objects_v2_params,
|
||||||
};
|
};
|
||||||
use crate::storage::s3_api::common::rustfs_owner;
|
use crate::storage::s3_api::common::rustfs_owner;
|
||||||
use crate::storage::s3_api::{acl, tagging};
|
|
||||||
use crate::storage::*;
|
use crate::storage::*;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
@@ -1333,7 +1333,7 @@ impl DefaultBucketUsecase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(S3Response::new(tagging::build_get_bucket_tagging_output(tag_set)))
|
Ok(S3Response::new(GetBucketTaggingOutput { tag_set }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
@@ -2397,6 +2397,20 @@ mod tests {
|
|||||||
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn execute_get_bucket_tagging_returns_internal_error_when_store_uninitialized() {
|
||||||
|
let input = GetBucketTaggingInput::builder()
|
||||||
|
.bucket("test-bucket".to_string())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let req = build_request(input, Method::GET);
|
||||||
|
let usecase = DefaultBucketUsecase::without_context();
|
||||||
|
|
||||||
|
let err = usecase.execute_get_bucket_tagging(req).await.unwrap_err();
|
||||||
|
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn execute_get_bucket_versioning_returns_internal_error_when_store_uninitialized() {
|
async fn execute_get_bucket_versioning_returns_internal_error_when_store_uninitialized() {
|
||||||
let input = GetBucketVersioningInput::builder()
|
let input = GetBucketVersioningInput::builder()
|
||||||
|
|||||||
@@ -12,7 +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::{DeleteObjectTaggingOutput, GetBucketTaggingOutput, GetObjectTaggingOutput, PutObjectTaggingOutput, Tag};
|
use s3s::dto::Tag;
|
||||||
use s3s::{S3Error, S3ErrorCode, S3Result};
|
use s3s::{S3Error, S3ErrorCode, S3Result};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
@@ -54,28 +54,9 @@ pub(crate) fn validate_object_tag_set(tag_set: &[Tag]) -> S3Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_get_bucket_tagging_output(tag_set: Vec<Tag>) -> GetBucketTaggingOutput {
|
|
||||||
GetBucketTaggingOutput { tag_set }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn build_get_object_tagging_output(tag_set: Vec<Tag>, version_id: Option<String>) -> GetObjectTaggingOutput {
|
|
||||||
GetObjectTaggingOutput { tag_set, version_id }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn build_put_object_tagging_output(version_id: Option<String>) -> PutObjectTaggingOutput {
|
|
||||||
PutObjectTaggingOutput { version_id }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn build_delete_object_tagging_output(version_id: Option<String>) -> DeleteObjectTaggingOutput {
|
|
||||||
DeleteObjectTaggingOutput { version_id }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::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::S3ErrorCode;
|
||||||
use s3s::dto::Tag;
|
use s3s::dto::Tag;
|
||||||
|
|
||||||
@@ -146,21 +127,4 @@ mod tests {
|
|||||||
assert_eq!(*err.code(), S3ErrorCode::InvalidTag);
|
assert_eq!(*err.code(), S3ErrorCode::InvalidTag);
|
||||||
assert!(err.to_string().contains("Cannot provide multiple Tags with the same key"));
|
assert!(err.to_string().contains("Cannot provide multiple Tags with the same key"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_build_tagging_outputs_preserve_fields() {
|
|
||||||
let tag_set = vec![tag(Some("k1"), Some("v1"))];
|
|
||||||
let version_id = Some("vid-1".to_string());
|
|
||||||
|
|
||||||
let bucket_output = build_get_bucket_tagging_output(tag_set.clone());
|
|
||||||
let get_object_output = build_get_object_tagging_output(tag_set.clone(), version_id.clone());
|
|
||||||
let put_object_output = build_put_object_tagging_output(version_id.clone());
|
|
||||||
let delete_object_output = build_delete_object_tagging_output(version_id.clone());
|
|
||||||
|
|
||||||
assert_eq!(bucket_output.tag_set, tag_set);
|
|
||||||
assert_eq!(get_object_output.tag_set, vec![tag(Some("k1"), Some("v1"))]);
|
|
||||||
assert_eq!(get_object_output.version_id, version_id);
|
|
||||||
assert_eq!(put_object_output.version_id, Some("vid-1".to_string()));
|
|
||||||
assert_eq!(delete_object_output.version_id, Some("vid-1".to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user