mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-12 16:16:55 +00:00
test(ecstore): pin persisted metadata key literals and bucket config goldens (#5904)
This commit is contained in:
@@ -453,6 +453,11 @@ pub mod rpc {
|
||||
pub mod set_disk {
|
||||
pub use crate::set_disk::{DEFAULT_READ_BUFFER_SIZE, SetDisks, get_lock_acquire_timeout, is_valid_storage_class};
|
||||
|
||||
/// Return the canonical object-metadata identity used for read-quorum grouping.
|
||||
pub fn file_info_quorum_hash(meta: &rustfs_filemeta::FileInfo) -> [u8; 32] {
|
||||
crate::set_disk::SetDisks::file_info_quorum_hash(meta)
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-util")]
|
||||
pub mod test_util {
|
||||
pub use crate::set_disk::{PutObjectCommitBarrier, PutObjectCommitPause};
|
||||
|
||||
@@ -200,6 +200,29 @@ mod tests {
|
||||
assert!(retention.retain_until_date.is_some());
|
||||
}
|
||||
|
||||
/// backlog#1733 g-key-002: the persisted literal keys must still be read
|
||||
/// through the current header constants, or WORM metadata fails open.
|
||||
#[test]
|
||||
fn persisted_compliance_lock_metadata_remains_effective() {
|
||||
let mut meta = HashMap::new();
|
||||
meta.insert("x-amz-object-lock-mode".to_string(), "COMPLIANCE".to_string());
|
||||
meta.insert("x-amz-object-lock-retain-until-date".to_string(), "9999-01-01T00:00:00Z".to_string());
|
||||
meta.insert("x-amz-object-lock-legal-hold".to_string(), "ON".to_string());
|
||||
|
||||
let retention = get_object_retention_meta(&meta);
|
||||
assert_eq!(
|
||||
retention.mode.as_ref().map(|mode| mode.as_str()),
|
||||
Some(ObjectLockRetentionMode::COMPLIANCE)
|
||||
);
|
||||
assert!(retention.retain_until_date.is_some(), "persisted retention date must remain readable");
|
||||
|
||||
let legal_hold = get_object_legalhold_meta(&meta);
|
||||
assert_eq!(
|
||||
legal_hold.status.as_ref().map(|status| status.as_str()),
|
||||
Some(ObjectLockLegalHoldStatus::ON)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_object_legalhold_meta_empty() {
|
||||
let meta = HashMap::new();
|
||||
|
||||
@@ -580,7 +580,7 @@ impl SetDisks {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn file_info_quorum_hash(meta: &FileInfo) -> [u8; 32] {
|
||||
pub(crate) fn file_info_quorum_hash(meta: &FileInfo) -> [u8; 32] {
|
||||
let mut hasher = Sha256::new();
|
||||
Self::update_file_info_quorum_hash(&mut hasher, meta);
|
||||
let digest = hasher.finalize();
|
||||
|
||||
Reference in New Issue
Block a user