From 2763f105f4b08c35db9df724aa4ff038af9404f5 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 17 Dec 2025 00:21:32 -0800 Subject: [PATCH] fix: use unique bucket name in TestS3IAMPresignedURLIntegration to avoid flaky test (#7801) The test was using a static bucket name 'test-iam-bucket' that could conflict with buckets created by other tests or previous runs. Each test framework creates new RSA keys for JWT signing, so the 'admin-user' identity differs between runs. When the bucket exists from a previous test, the new admin cannot access or delete it, causing AccessDenied errors. Changed to use GenerateUniqueBucketName() which ensures each test run gets its own bucket, avoiding cross-test conflicts. --- test/s3/iam/s3_iam_integration_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/s3/iam/s3_iam_integration_test.go b/test/s3/iam/s3_iam_integration_test.go index dcf8422b4..ecf5f0eba 100644 --- a/test/s3/iam/s3_iam_integration_test.go +++ b/test/s3/iam/s3_iam_integration_test.go @@ -558,13 +558,14 @@ func TestS3IAMPresignedURLIntegration(t *testing.T) { adminClient, err := framework.CreateS3ClientWithJWT("admin-user", "TestAdminRole") require.NoError(t, err) - // Use static bucket name but with cleanup to handle conflicts - err = framework.CreateBucketWithCleanup(adminClient, testBucket) + // Use unique bucket name to avoid conflicts with other tests + bucketName := framework.GenerateUniqueBucketName("test-iam-presigned") + err = framework.CreateBucket(adminClient, bucketName) require.NoError(t, err) // Put test object _, err = adminClient.PutObject(&s3.PutObjectInput{ - Bucket: aws.String(testBucket), + Bucket: aws.String(bucketName), Key: aws.String(testObjectKey), Body: strings.NewReader(testObjectData), }) @@ -586,7 +587,7 @@ func TestS3IAMPresignedURLIntegration(t *testing.T) { // Test direct object access with JWT Bearer token (recommended approach) _, err := adminClient.GetObject(&s3.GetObjectInput{ - Bucket: aws.String(testBucket), + Bucket: aws.String(bucketName), Key: aws.String(testObjectKey), }) require.NoError(t, err, "Direct object access with JWT Bearer token works correctly") @@ -597,13 +598,13 @@ func TestS3IAMPresignedURLIntegration(t *testing.T) { // Cleanup _, err = adminClient.DeleteObject(&s3.DeleteObjectInput{ - Bucket: aws.String(testBucket), + Bucket: aws.String(bucketName), Key: aws.String(testObjectKey), }) require.NoError(t, err) _, err = adminClient.DeleteBucket(&s3.DeleteBucketInput{ - Bucket: aws.String(testBucket), + Bucket: aws.String(bucketName), }) require.NoError(t, err) }