fix tests

This commit is contained in:
chrislu
2025-07-18 16:47:25 -07:00
parent f419271299
commit c5628b000b
3 changed files with 29 additions and 13 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
host = 127.0.0.1
# port set for rgw in vstart.sh
port = 8000
port = 8333
## say "False" to disable TLS
is_secure = False
+4
View File
@@ -600,6 +600,10 @@ func mapValidationErrorToS3Error(err error) s3err.ErrorCode {
// For malformed XML in request body, return MalformedXML
// This matches the test expectations for invalid retention mode and legal hold status
return s3err.ErrMalformedXML
case errors.Is(err, ErrInvalidRetentionPeriod):
// For invalid retention period (e.g., Days <= 0), return InvalidRetentionPeriod
// This matches the test expectations
return s3err.ErrInvalidRetentionPeriod
// Validation error constants
case errors.Is(err, ErrObjectLockConfigurationMissingEnabled):
return s3err.ErrMalformedXML
+24 -12
View File
@@ -226,26 +226,38 @@ func validateDefaultRetention(retention *DefaultRetention) error {
return ErrInvalidDefaultRetentionMode
}
// Exactly one of Days or Years must be specified
if retention.Days == 0 && retention.Years == 0 {
return ErrDefaultRetentionMissingPeriod
// Check for invalid Years value (negative values are always invalid)
if retention.Years < 0 {
return ErrInvalidRetentionPeriod
}
// Check for invalid Days value (negative values are invalid)
if retention.Days < 0 {
return ErrInvalidRetentionPeriod
}
// Check for Days: 0 when Years is also 0 (this should return InvalidRetentionPeriod)
if retention.Days == 0 && retention.Years == 0 {
return ErrInvalidRetentionPeriod
}
// Check for both Days and Years being specified
if retention.Days > 0 && retention.Years > 0 {
return ErrDefaultRetentionBothDaysAndYears
}
// Validate ranges - Days must be greater than 0
if retention.Days <= 0 {
return ErrInvalidRetentionPeriod
// Validate Days if specified
if retention.Days > 0 {
if retention.Days > MaxRetentionDays {
return ErrDefaultRetentionDaysOutOfRange
}
}
if retention.Days > MaxRetentionDays {
return ErrDefaultRetentionDaysOutOfRange
}
if retention.Years < 0 || retention.Years > MaxRetentionYears {
return ErrDefaultRetentionYearsOutOfRange
// Validate Years if specified
if retention.Years > 0 {
if retention.Years > MaxRetentionYears {
return ErrDefaultRetentionYearsOutOfRange
}
}
return nil