test(replication): cover rule id byte limit (#5873)

This commit is contained in:
Zhengchao An
2026-08-09 14:48:44 +08:00
committed by GitHub
parent c619d8f2d6
commit a07ad4a9ff
+27
View File
@@ -794,6 +794,33 @@ mod tests {
);
}
#[test]
fn structure_validation_counts_rule_id_limit_in_bytes() {
let mut within_byte_limit = replication_rule(&"\u{00e9}".repeat(127), "arn:target:a");
within_byte_limit.priority = Some(1);
assert_eq!(
within_byte_limit.id.as_ref().expect("rule id should be present").len(),
REPLICATION_CONFIG_MAX_RULE_ID_LEN - 1
);
assert_eq!(validate_replication_config_structure(&structure_config(vec![within_byte_limit])), Ok(()));
let mut over_byte_limit = replication_rule(&"\u{00e9}".repeat(128), "arn:target:a");
over_byte_limit.priority = Some(1);
assert!(
over_byte_limit
.id
.as_ref()
.expect("rule id should be present")
.chars()
.count()
< REPLICATION_CONFIG_MAX_RULE_ID_LEN
);
assert_eq!(
validate_replication_config_structure(&structure_config(vec![over_byte_limit])),
Err(ReplicationConfigStructureError::RuleIdTooLong)
);
}
#[test]
fn structure_validation_rejects_filter_with_both_prefix_and_tag() {
let mut rule = replication_rule("rule-1", "arn:target:a");