diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-11-20 11:42:22 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-20 11:42:22 -0800 |
| commit | 5f77f8733511d6d2bc4f47df7c477c4f9c25a727 (patch) | |
| tree | 10c58807bcba42022c8ccb6df44f181297d2b40a /weed/s3api/s3api_object_retention_test.go | |
| parent | 6281e62d7f6cfbc6632de05829897bbd0fd2c992 (diff) | |
| download | seaweedfs-5f77f8733511d6d2bc4f47df7c477c4f9c25a727.tar.xz seaweedfs-5f77f8733511d6d2bc4f47df7c477c4f9c25a727.zip | |
S3: S3 Object Retention API to include XML namespace support (#7517)
* Refactor S3 Object Retention API to include XML namespace support and improve compatibility with Veeam. Updated XML tags to remove hardcoded namespaces and added test cases for retention and legal hold configurations without namespaces.
* Added XMLNS field setting in both places
Diffstat (limited to 'weed/s3api/s3api_object_retention_test.go')
| -rw-r--r-- | weed/s3api/s3api_object_retention_test.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/weed/s3api/s3api_object_retention_test.go b/weed/s3api/s3api_object_retention_test.go index 20ccf60d9..34c772acd 100644 --- a/weed/s3api/s3api_object_retention_test.go +++ b/weed/s3api/s3api_object_retention_test.go @@ -202,6 +202,30 @@ func TestParseObjectRetention(t *testing.T) { }, }, { + name: "Valid retention XML without namespace (Veeam compatibility)", + xmlBody: `<Retention> + <Mode>GOVERNANCE</Mode> + <RetainUntilDate>2024-12-31T23:59:59Z</RetainUntilDate> + </Retention>`, + expectError: false, + expectedResult: &ObjectRetention{ + Mode: "GOVERNANCE", + RetainUntilDate: timePtr(time.Date(2024, 12, 31, 23, 59, 59, 0, time.UTC)), + }, + }, + { + name: "Valid compliance retention XML without namespace (Veeam compatibility)", + xmlBody: `<Retention> + <Mode>COMPLIANCE</Mode> + <RetainUntilDate>2025-01-01T00:00:00Z</RetainUntilDate> + </Retention>`, + expectError: false, + expectedResult: &ObjectRetention{ + Mode: "COMPLIANCE", + RetainUntilDate: timePtr(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)), + }, + }, + { name: "Empty XML body", xmlBody: "", expectError: true, @@ -312,6 +336,26 @@ func TestParseObjectLegalHold(t *testing.T) { }, }, { + name: "Valid legal hold ON without namespace", + xmlBody: `<LegalHold> + <Status>ON</Status> + </LegalHold>`, + expectError: false, + expectedResult: &ObjectLegalHold{ + Status: "ON", + }, + }, + { + name: "Valid legal hold OFF without namespace", + xmlBody: `<LegalHold> + <Status>OFF</Status> + </LegalHold>`, + expectError: false, + expectedResult: &ObjectLegalHold{ + Status: "OFF", + }, + }, + { name: "Empty XML body", xmlBody: "", expectError: true, @@ -406,6 +450,38 @@ func TestParseObjectLockConfiguration(t *testing.T) { }, }, { + name: "Valid object lock configuration without namespace", + xmlBody: `<ObjectLockConfiguration> + <ObjectLockEnabled>Enabled</ObjectLockEnabled> + </ObjectLockConfiguration>`, + expectError: false, + expectedResult: &ObjectLockConfiguration{ + ObjectLockEnabled: "Enabled", + }, + }, + { + name: "Valid object lock configuration with rule without namespace", + xmlBody: `<ObjectLockConfiguration> + <ObjectLockEnabled>Enabled</ObjectLockEnabled> + <Rule> + <DefaultRetention> + <Mode>GOVERNANCE</Mode> + <Days>30</Days> + </DefaultRetention> + </Rule> + </ObjectLockConfiguration>`, + expectError: false, + expectedResult: &ObjectLockConfiguration{ + ObjectLockEnabled: "Enabled", + Rule: &ObjectLockRule{ + DefaultRetention: &DefaultRetention{ + Mode: "GOVERNANCE", + Days: 30, + }, + }, + }, + }, + { name: "Empty XML body", xmlBody: "", expectError: true, |
