From 5e97377aa00cb79003d79416f254a3a01a54b738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sat, 11 Apr 2026 11:49:10 +0800 Subject: [PATCH] refactor(storage): drop ecfs test-only helper (#2484) --- rustfs/src/app/object_usecase.rs | 27 +++++++++++++++++++++++++++ rustfs/src/storage/ecfs.rs | 19 ------------------- rustfs/src/storage/ecfs_test.rs | 25 ------------------------- 3 files changed, 27 insertions(+), 44 deletions(-) diff --git a/rustfs/src/app/object_usecase.rs b/rustfs/src/app/object_usecase.rs index c29ffd8b5..4054f2222 100644 --- a/rustfs/src/app/object_usecase.rs +++ b/rustfs/src/app/object_usecase.rs @@ -3088,6 +3088,33 @@ mod tests { assert_eq!(err.code(), &S3ErrorCode::InvalidStorageClass); } + #[test] + fn normalize_delete_objects_version_id_handles_null_uuid_and_empty_values() { + let (raw, uuid) = normalize_delete_objects_version_id(Some("null".to_string())).unwrap(); + assert_eq!(raw.as_deref(), Some("null")); + assert_eq!(uuid, Some(Uuid::nil())); + + let (raw, uuid) = normalize_delete_objects_version_id(Some(String::new())).unwrap(); + assert!(raw.is_none()); + assert!(uuid.is_none()); + + let (raw, uuid) = normalize_delete_objects_version_id(Some(" ".to_string())).unwrap(); + assert!(raw.is_none()); + assert!(uuid.is_none()); + + let valid = "550e8400-e29b-41d4-a716-446655440000".to_string(); + let (raw, uuid) = normalize_delete_objects_version_id(Some(valid.clone())).unwrap(); + assert_eq!(raw.as_deref(), Some(valid.as_str())); + assert_eq!(uuid, Some(Uuid::parse_str(&valid).unwrap())); + + let err = normalize_delete_objects_version_id(Some("not-a-uuid".to_string())).unwrap_err(); + assert!(!err.is_empty()); + + let (raw, uuid) = normalize_delete_objects_version_id(None).unwrap(); + assert!(raw.is_none()); + assert!(uuid.is_none()); + } + #[tokio::test] async fn execute_put_object_tagging_rejects_too_many_tags() { let tag_set = (0..11) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 2be0022a0..7289b0453 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -103,25 +103,6 @@ impl FS { } Ok(out) } - - #[cfg(test)] - pub(crate) fn normalize_delete_objects_version_id( - &self, - version_id: Option, - ) -> std::result::Result<(Option, Option), String> { - let version_id = version_id.map(|v| v.trim().to_string()).filter(|v| !v.is_empty()); - match version_id { - Some(id) => { - if id.eq_ignore_ascii_case("null") { - Ok((Some("null".to_string()), Some(Uuid::nil()))) - } else { - let uuid = Uuid::parse_str(&id).map_err(|e| e.to_string())?; - Ok((Some(id), Some(uuid))) - } - } - None => Ok((None, None)), - } - } } pub(crate) fn parse_object_version_id(version_id: Option) -> S3Result> { diff --git a/rustfs/src/storage/ecfs_test.rs b/rustfs/src/storage/ecfs_test.rs index 5de326553..fdff43104 100644 --- a/rustfs/src/storage/ecfs_test.rs +++ b/rustfs/src/storage/ecfs_test.rs @@ -856,31 +856,6 @@ mod tests { assert_eq!(formatted, "550e8400-e29b-41d4-a716-446655440000"); } - #[test] - fn test_delete_objects_version_id_normalization() { - use uuid::Uuid; - - let fs = FS::new(); - - let (raw, uuid) = fs.normalize_delete_objects_version_id(Some("null".to_string())).unwrap(); - assert_eq!(raw.as_deref(), Some("null")); - assert_eq!(uuid, Some(Uuid::nil())); - - let valid = "550e8400-e29b-41d4-a716-446655440000".to_string(); - let (raw, uuid) = fs.normalize_delete_objects_version_id(Some(valid.clone())).unwrap(); - assert_eq!(raw.as_deref(), Some(valid.as_str())); - assert_eq!(uuid, Some(Uuid::parse_str(&valid).unwrap())); - - let err = fs - .normalize_delete_objects_version_id(Some("not-a-uuid".to_string())) - .unwrap_err(); - assert!(!err.is_empty()); - - let (raw, uuid) = fs.normalize_delete_objects_version_id(None).unwrap(); - assert!(raw.is_none()); - assert!(uuid.is_none()); - } - /// Test that ListObjectVersionsOutput markers are correctly set /// This verifies the fix for boto3 ParamValidationError #[test]