mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-06 08:07:05 +00:00
fix tests
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user