From eefd411099b5c9cd82cb07a2000b1bbdfb824215 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 21 Nov 2024 16:02:05 +1300 Subject: [PATCH] testsuite/server: add test for unversioned bucket lock config Change-Id: I57dbcad9a4ddf640fbfd873ede9ba1e65936d7af --- testsuite/server/integration_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testsuite/server/integration_test.go b/testsuite/server/integration_test.go index 8cd4f818..105b5850 100644 --- a/testsuite/server/integration_test.go +++ b/testsuite/server/integration_test.go @@ -245,6 +245,7 @@ func TestObjectLock(t *testing.T) { Satellite: func(log *zap.Logger, index int, config *satellite.Config) { config.Metainfo.ObjectLockEnabled = true config.Metainfo.UseBucketLevelObjectVersioning = true + config.Metainfo.ProjectLimits.MaxBuckets = 100 }, Uplink: func(log *zap.Logger, index int, config *testplanet.UplinkConfig) { config.APIKeyVersion = macaroon.APIKeyVersionObjectLock @@ -330,6 +331,22 @@ func TestObjectLock(t *testing.T) { requireS3Error(t, deleteObject(ctx, client, lockBucket, objKey1, *putObjResp.VersionId), http.StatusForbidden, "AccessDenied") }) + t.Run("put object lock config on unversioned bucket not allowed", func(t *testing.T) { + bucket := testrand.BucketName() + require.NoError(t, createBucket(ctx, client, bucket, false, false)) + + retDays := int64(5) + retMode := s3.ObjectLockRetentionModeCompliance + + _, err := putObjectLockConfiguration(ctx, client, bucket, "Enabled", &s3.ObjectLockRule{ + DefaultRetention: &s3.DefaultRetention{ + Days: &retDays, + Mode: &retMode, + }, + }) + requireS3Error(t, err, http.StatusConflict, "InvalidBucketState") + }) + t.Run("put object with lock not allowed on unversioned bucket", func(t *testing.T) { noVersioningBucket := testrand.BucketName() require.NoError(t, createBucket(ctx, client, noVersioningBucket, false, false))