From d9b3778e1a38dc2fbe6057ec3dcc2e35f13b8a42 Mon Sep 17 00:00:00 2001 From: Nikita Pivkin Date: Tue, 26 Nov 2024 21:01:31 +0600 Subject: [PATCH] refactor(test): use s3 canned acl Signed-off-by: Nikita Pivkin --- internal/adapters/cloud/aws/s3/s3_test.go | 26 ++++++----------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/internal/adapters/cloud/aws/s3/s3_test.go b/internal/adapters/cloud/aws/s3/s3_test.go index 14d122e..d2faad0 100644 --- a/internal/adapters/cloud/aws/s3/s3_test.go +++ b/internal/adapters/cloud/aws/s3/s3_test.go @@ -25,7 +25,7 @@ type publicAccessBlock struct { type bucketDetails struct { bucketName string - acl string + acl s3types.BucketCannedACL encrypted bool loggingEnabled bool loggingTargetBucket string @@ -43,7 +43,7 @@ func Test_S3BucketACLs(t *testing.T) { name: "simple bucket with public-read acl", details: bucketDetails{ bucketName: "test-bucket", - acl: "public-read", + acl: s3types.BucketCannedACLPublicRead, encrypted: false, }, }, @@ -51,7 +51,7 @@ func Test_S3BucketACLs(t *testing.T) { name: "simple bucket with authenticated-read acl", details: bucketDetails{ bucketName: "wide-open-bucket", - acl: "authenticated-read", + acl: s3types.BucketCannedACLAuthenticatedRead, encrypted: false, }, }, @@ -59,7 +59,7 @@ func Test_S3BucketACLs(t *testing.T) { name: "simple bucket with public-read-write acl", details: bucketDetails{ bucketName: "public-read-write-bucket", - acl: "public-read-write", + acl: s3types.BucketCannedACLPublicReadWrite, encrypted: false, }, }, @@ -67,7 +67,7 @@ func Test_S3BucketACLs(t *testing.T) { name: "simple bucket with private acl and encryption", details: bucketDetails{ bucketName: "private-bucket", - acl: "private", + acl: s3types.BucketCannedACLPrivate, encrypted: true, }, }, @@ -296,8 +296,7 @@ func bootstrapBucket(t *testing.T, ra *aws.RootAdapter, spec bucketDetails) { _, err := api.CreateBucket(ra.Context(), &s3api.CreateBucketInput{ Bucket: awssdk.String(spec.bucketName), - - ACL: aclToCannedACL(spec.acl), + ACL: spec.acl, }) require.NoError(t, err) @@ -386,19 +385,6 @@ func createPublicAccessBlock(t *testing.T, api *s3api.Client, ctx context.Contex require.NoError(t, err) } -func aclToCannedACL(acl string) s3types.BucketCannedACL { - switch acl { - case "authenticated-read": - return s3types.BucketCannedACLAuthenticatedRead - case "public-read": - return s3types.BucketCannedACLPublicRead - case "public-read-write": - return s3types.BucketCannedACLPublicReadWrite - default: - return s3types.BucketCannedACLPrivate - } -} - func removeBucket(t *testing.T, ra *aws.RootAdapter, spec bucketDetails) { api := s3api.NewFromConfig(ra.SessionConfig())