Files
seaweedFS/test/s3/iam/s3_iam_distributed_test.go
Chris Lu 06391701ed Add AssumeRole and AssumeRoleWithLDAPIdentity STS actions (#8003)
* test: add integration tests for AssumeRole and AssumeRoleWithLDAPIdentity STS actions

- Add s3_sts_assume_role_test.go with comprehensive tests for AssumeRole:
  * Parameter validation (missing RoleArn, RoleSessionName, invalid duration)
  * AWS SigV4 authentication with valid/invalid credentials
  * Temporary credential generation and usage

- Add s3_sts_ldap_test.go with tests for AssumeRoleWithLDAPIdentity:
  * Parameter validation (missing LDAP credentials, RoleArn)
  * LDAP authentication scenarios (valid/invalid credentials)
  * Integration with LDAP server (when configured)

- Update Makefile with new test targets:
  * test-sts: run all STS tests
  * test-sts-assume-role: run AssumeRole tests only
  * test-sts-ldap: run LDAP STS tests only
  * test-sts-suite: run tests with full service lifecycle

- Enhance setup_all_tests.sh:
  * Add OpenLDAP container setup for LDAP testing
  * Create test LDAP users (testuser, ldapadmin)
  * Set LDAP environment variables for tests
  * Update cleanup to remove LDAP container

- Fix setup_keycloak.sh:
  * Enable verbose error logging for realm creation
  * Improve error diagnostics

Tests use fail-fast approach (t.Fatal) when server not configured,
ensuring clear feedback when infrastructure is missing.

* feat: implement AssumeRole and AssumeRoleWithLDAPIdentity STS actions

Implement two new STS actions to match MinIO's STS feature set:

**AssumeRole Implementation:**
- Add handleAssumeRole with full AWS SigV4 authentication
- Integrate with existing IAM infrastructure via verifyV4Signature
- Validate required parameters (RoleArn, RoleSessionName)
- Validate DurationSeconds (900-43200 seconds range)
- Generate temporary credentials with expiration
- Return AWS-compatible XML response

**AssumeRoleWithLDAPIdentity Implementation:**
- Add handleAssumeRoleWithLDAPIdentity handler (stub)
- Validate LDAP-specific parameters (LDAPUsername, LDAPPassword)
- Validate common STS parameters (RoleArn, RoleSessionName, DurationSeconds)
- Return proper error messages for missing LDAP provider
- Ready for LDAP provider integration

**Routing Fixes:**
- Add explicit routes for AssumeRole and AssumeRoleWithLDAPIdentity
- Prevent IAM handler from intercepting authenticated STS requests
- Ensure proper request routing priority

**Handler Infrastructure:**
- Add IAM field to STSHandlers for SigV4 verification
- Update NewSTSHandlers to accept IAM reference
- Add STS-specific error codes and response types
- Implement writeSTSErrorResponse for AWS-compatible errors

The AssumeRole action is fully functional and tested.
AssumeRoleWithLDAPIdentity requires LDAP provider implementation.

* fix: update IAM matcher to exclude STS actions from interception

Update the IAM handler matcher to check for STS actions (AssumeRole,
AssumeRoleWithWebIdentity, AssumeRoleWithLDAPIdentity) and exclude them
from IAM handler processing. This allows STS requests to be handled by
the STS fallback handler even when they include AWS SigV4 authentication.

The matcher now parses the form data to check the Action parameter and
returns false for STS actions, ensuring they are routed to the correct
handler.

Note: This is a work-in-progress fix. Tests are still showing some
routing issues that need further investigation.

* fix: address PR review security issues for STS handlers

This commit addresses all critical security issues from PR review:

Security Fixes:
- Use crypto/rand for cryptographically secure credential generation
  instead of time.Now().UnixNano() (fixes predictable credentials)
- Add sts:AssumeRole permission check via VerifyActionPermission to
  prevent unauthorized role assumption
- Generate proper session tokens using crypto/rand instead of
  placeholder strings

Code Quality Improvements:
- Refactor DurationSeconds parsing into reusable parseDurationSeconds()
  helper function used by all three STS handlers
- Create generateSecureCredentials() helper for consistent and secure
  temporary credential generation
- Fix iamMatcher to check query string as fallback when Action not
  found in form data

LDAP Provider Implementation:
- Add go-ldap/ldap/v3 dependency
- Create LDAPProvider implementing IdentityProvider interface with
  full LDAP authentication support (connect, bind, search, groups)
- Update ProviderFactory to create real LDAP providers
- Wire LDAP provider into AssumeRoleWithLDAPIdentity handler

Test Infrastructure:
- Add LDAP user creation verification step in setup_all_tests.sh

* fix: address PR feedback (Round 2) - config validation & provider improvements

- Implement `validateLDAPConfig` in `ProviderFactory`
- Improve `LDAPProvider.Initialize`:
  - Support `connectionTimeout` parsing (string/int/float) from config map
  - Warn if `BindDN` is present but `BindPassword` is empty
- Improve `LDAPProvider.GetUserInfo`:
  - Add fallback to `searchUserGroups` if `memberOf` returns no groups (consistent with Authenticate)

* fix: address PR feedback (Round 3) - LDAP connection improvements & build fix

- Improve `LDAPProvider` connection handling:
  - Use `net.Dialer` with configured timeout for connection establishment
  - Enforce TLS 1.2+ (`MinVersion: tls.VersionTLS12`) for both LDAPS and StartTLS
- Fix build error in `s3api_sts.go` (format verb for ErrorCode)

* fix: address PR feedback (Round 4) - LDAP hardening, Authz check & Routing fix

- LDAP Provider Hardening:
  - Prevent re-initialization
  - Enforce single user match in `GetUserInfo` (was explicit only in Authenticate)
  - Ensure connection closure if StartTLS fails
- STS Handlers:
  - Add robust provider detection using type assertion
  - **Security**: Implement authorization check (`VerifyActionPermission`) after LDAP authentication
- Routing:
  - Update tests to reflect that STS actions are handled by STS handler, not generic IAM

* fix: address PR feedback (Round 5) - JWT tokens, ARN formatting, PrincipalArn

CRITICAL FIXES:
- Replace standalone credential generation with STS service JWT tokens
  - handleAssumeRole now generates proper JWT session tokens
  - handleAssumeRoleWithLDAPIdentity now generates proper JWT session tokens
  - Session tokens can be validated across distributed instances

- Fix ARN formatting in responses
  - Extract role name from ARN using utils.ExtractRoleNameFromArn()
  - Prevents malformed ARNs like "arn:aws:sts::assumed-role/arn:aws:iam::..."

- Add configurable AccountId for federated users
  - Add AccountId field to STSConfig (defaults to "111122223333")
  - PrincipalArn now uses configured account ID instead of hardcoded "aws"
  - Enables proper trust policy validation

IMPROVEMENTS:
- Sanitize LDAP authentication error messages (don't leak internal details)
- Remove duplicate comment in provider detection
- Add utils import for ARN parsing utilities

* feat: implement LDAP connection pooling to prevent resource exhaustion

PERFORMANCE IMPROVEMENT:
- Add connection pool to LDAPProvider (default size: 10 connections)
- Reuse LDAP connections across authentication requests
- Prevent file descriptor exhaustion under high load

IMPLEMENTATION:
- connectionPool struct with channel-based connection management
- getConnection(): retrieves from pool or creates new connection
- returnConnection(): returns healthy connections to pool
- createConnection(): establishes new LDAP connection with TLS support
- Close(): cleanup method to close all pooled connections
- Connection health checking (IsClosing()) before reuse

BENEFITS:
- Reduced connection overhead (no TCP handshake per request)
- Better resource utilization under load
- Prevents "too many open files" errors
- Non-blocking pool operations (creates new conn if pool empty)

* fix: correct TokenGenerator access in STS handlers

CRITICAL FIX:
- Make TokenGenerator public in STSService (was private tokenGenerator)
- Update all references from Config.TokenGenerator to TokenGenerator
- Remove TokenGenerator from STSConfig (it belongs in STSService)

This fixes the "NotImplemented" errors in distributed and Keycloak tests.
The issue was that Round 5 changes tried to access Config.TokenGenerator
which didn't exist - TokenGenerator is a field in STSService, not STSConfig.

The TokenGenerator is properly initialized in STSService.Initialize() and
is now accessible for JWT token generation in AssumeRole handlers.

* fix: update tests to use public TokenGenerator field

Following the change to make TokenGenerator public in STSService,
this commit updates the test files to reference the correct public field name.
This resolves compilation errors in the IAM STS test suite.

* fix: update distributed tests to use valid Keycloak users

Updated s3_iam_distributed_test.go to use 'admin-user' and 'read-user'
which exist in the standard Keycloak setup provided by setup_keycloak.sh.
This resolves 'unknown test user' errors in distributed integration tests.

* fix: ensure iam_config.json exists in setup target for CI

The GitHub Actions workflow calls 'make setup' which was not creating
iam_config.json, causing the server to start without IAM integration
enabled (iamIntegration = nil), resulting in NotImplemented errors.

Now 'make setup' copies iam_config.local.json to iam_config.json if
it doesn't exist, ensuring IAM is properly configured in CI.

* fix(iam/ldap): fix connection pool race and rebind corruption

- Add atomic 'closed' flag to connection pool to prevent racing on Close()
- Rebind authenticated user connections back to service account before returning to pool
- Close connections on error instead of returning potentially corrupted state to pool

* fix(iam/ldap): populate standard TokenClaims fields in ValidateToken

- Set Subject, Issuer, Audience, IssuedAt, and ExpiresAt to satisfy the interface
- Use time.Time for timestamps as required by TokenClaims struct
- Default to 1 hour TTL for LDAP tokens

* fix(s3api): include account ID in STS AssumedRoleUser ARN

- Consistent with AWS, include the account ID in the assumed-role ARN
- Use the configured account ID from STS service if available, otherwise default to '111122223333'
- Apply to both AssumeRole and AssumeRoleWithLDAPIdentity handlers
- Also update .gitignore to ignore IAM test environment files

* refactor(s3api): extract shared STS credential generation logic

- Move common logic for session claims and credential generation to prepareSTSCredentials
- Update handleAssumeRole and handleAssumeRoleWithLDAPIdentity to use the helper
- Remove stale comments referencing outdated line numbers

* feat(iam/ldap): make pool size configurable and add audience support

- Add PoolSize to LDAPConfig (default 10)
- Add Audience to LDAPConfig to align with OIDC validation
- Update initialization and ValidateToken to use new fields

* update tests

* debug

* chore(iam): cleanup debug prints and fix test config port

* refactor(iam): use mapstructure for LDAP config parsing

* feat(sts): implement strict trust policy validation for AssumeRole

* test(iam): refactor STS tests to use AWS SDK signer

* test(s3api): implement ValidateTrustPolicyForPrincipal in MockIAMIntegration

* fix(s3api): ensure IAM matcher checks query string on ParseForm error

* fix(sts): use crypto/rand for secure credentials and extract constants

* fix(iam): fix ldap connection leaks and add insecure warning

* chore(iam): improved error wrapping and test parameterization

* feat(sts): add support for LDAPProviderName parameter

* Update weed/iam/ldap/ldap_provider.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update weed/s3api/s3api_sts.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(sts): use STSErrSTSNotReady when LDAP provider is missing

* fix(sts): encapsulate TokenGenerator in STSService and add getter

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-12 10:45:24 -08:00

427 lines
14 KiB
Go

package iam
import (
"fmt"
"os"
"strings"
"sync"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestS3IAMDistributedTests tests IAM functionality across multiple S3 gateway instances
func TestS3IAMDistributedTests(t *testing.T) {
// Skip if not in distributed test mode
if os.Getenv("ENABLE_DISTRIBUTED_TESTS") != "true" {
t.Skip("Distributed tests not enabled. Set ENABLE_DISTRIBUTED_TESTS=true")
}
framework := NewS3IAMTestFramework(t)
defer framework.Cleanup()
t.Run("distributed_session_consistency", func(t *testing.T) {
// Test that sessions created on one instance are visible on others
// This requires filer-based session storage
// Create S3 clients that would connect to different gateway instances
// In a real distributed setup, these would point to different S3 gateway ports
client1, err := framework.CreateS3ClientWithJWT("admin-user", "TestAdminRole")
require.NoError(t, err)
client2, err := framework.CreateS3ClientWithJWT("admin-user", "TestAdminRole")
require.NoError(t, err)
// Both clients should be able to perform operations
bucketName := "test-distributed-session"
err = framework.CreateBucket(client1, bucketName)
require.NoError(t, err)
// Client2 should see the bucket created by client1
listResult, err := client2.ListBuckets(&s3.ListBucketsInput{})
require.NoError(t, err)
found := false
for _, bucket := range listResult.Buckets {
if *bucket.Name == bucketName {
found = true
break
}
}
assert.True(t, found, "Bucket should be visible across distributed instances")
// Cleanup
_, err = client1.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(t, err)
})
t.Run("distributed_role_consistency", func(t *testing.T) {
// Test that role definitions are consistent across instances
// This requires filer-based role storage
// Create clients with different roles
adminClient, err := framework.CreateS3ClientWithJWT("admin-user", "TestAdminRole")
require.NoError(t, err)
readOnlyClient, err := framework.CreateS3ClientWithJWT("read-user", "TestReadOnlyRole")
require.NoError(t, err)
bucketName := "test-distributed-roles"
objectKey := "test-object.txt"
// Admin should be able to create bucket
err = framework.CreateBucket(adminClient, bucketName)
require.NoError(t, err)
// Admin should be able to put object
err = framework.PutTestObject(adminClient, bucketName, objectKey, "test content")
require.NoError(t, err)
// Read-only user should be able to get object
content, err := framework.GetTestObject(readOnlyClient, bucketName, objectKey)
require.NoError(t, err)
assert.Equal(t, "test content", content)
// Read-only user should NOT be able to put object
err = framework.PutTestObject(readOnlyClient, bucketName, "forbidden-object.txt", "forbidden content")
require.Error(t, err, "Read-only user should not be able to put objects")
// Cleanup
err = framework.DeleteTestObject(adminClient, bucketName, objectKey)
require.NoError(t, err)
_, err = adminClient.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(t, err)
})
t.Run("distributed_concurrent_operations", func(t *testing.T) {
// Test concurrent operations across distributed instances with robust retry mechanisms
// This approach implements proper retry logic instead of tolerating errors to catch real concurrency issues
const numGoroutines = 3 // Reduced concurrency for better CI reliability
const numOperationsPerGoroutine = 2 // Minimal operations per goroutine
const maxRetries = 3 // Maximum retry attempts for transient failures
const retryDelay = 200 * time.Millisecond // Increased delay for better stability
var wg sync.WaitGroup
errors := make(chan error, numGoroutines*numOperationsPerGoroutine)
// Helper function to determine if an error is retryable
isRetryableError := func(err error) bool {
if err == nil {
return false
}
errorMsg := err.Error()
return strings.Contains(errorMsg, "timeout") ||
strings.Contains(errorMsg, "connection reset") ||
strings.Contains(errorMsg, "temporary failure") ||
strings.Contains(errorMsg, "TooManyRequests") ||
strings.Contains(errorMsg, "ServiceUnavailable") ||
strings.Contains(errorMsg, "InternalError")
}
// Helper function to execute operations with retry logic
executeWithRetry := func(operation func() error, operationName string) error {
var lastErr error
for attempt := 0; attempt <= maxRetries; attempt++ {
if attempt > 0 {
time.Sleep(retryDelay * time.Duration(attempt)) // Linear backoff
}
lastErr = operation()
if lastErr == nil {
return nil // Success
}
if !isRetryableError(lastErr) {
// Non-retryable error - fail immediately
return fmt.Errorf("%s failed with non-retryable error: %w", operationName, lastErr)
}
// Retryable error - continue to next attempt
if attempt < maxRetries {
t.Logf("Retrying %s (attempt %d/%d) after error: %v", operationName, attempt+1, maxRetries, lastErr)
}
}
// All retries exhausted
return fmt.Errorf("%s failed after %d retries, last error: %w", operationName, maxRetries, lastErr)
}
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
go func(goroutineID int) {
defer wg.Done()
client, err := framework.CreateS3ClientWithJWT("admin-user", "TestAdminRole")
if err != nil {
errors <- fmt.Errorf("failed to create S3 client for goroutine %d: %w", goroutineID, err)
return
}
for j := 0; j < numOperationsPerGoroutine; j++ {
bucketName := fmt.Sprintf("test-concurrent-%d-%d", goroutineID, j)
objectKey := "test-object.txt"
objectContent := fmt.Sprintf("content-%d-%d", goroutineID, j)
// Execute full operation sequence with individual retries
operationFailed := false
// 1. Create bucket with retry
if err := executeWithRetry(func() error {
return framework.CreateBucket(client, bucketName)
}, fmt.Sprintf("CreateBucket-%s", bucketName)); err != nil {
errors <- err
operationFailed = true
}
if !operationFailed {
// 2. Put object with retry
if err := executeWithRetry(func() error {
return framework.PutTestObject(client, bucketName, objectKey, objectContent)
}, fmt.Sprintf("PutObject-%s/%s", bucketName, objectKey)); err != nil {
errors <- err
operationFailed = true
}
}
if !operationFailed {
// 3. Get object with retry
if err := executeWithRetry(func() error {
_, err := framework.GetTestObject(client, bucketName, objectKey)
return err
}, fmt.Sprintf("GetObject-%s/%s", bucketName, objectKey)); err != nil {
errors <- err
operationFailed = true
}
}
if !operationFailed {
// 4. Delete object with retry
if err := executeWithRetry(func() error {
return framework.DeleteTestObject(client, bucketName, objectKey)
}, fmt.Sprintf("DeleteObject-%s/%s", bucketName, objectKey)); err != nil {
errors <- err
operationFailed = true
}
}
// 5. Always attempt bucket cleanup, even if previous operations failed
if err := executeWithRetry(func() error {
_, err := client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
return err
}, fmt.Sprintf("DeleteBucket-%s", bucketName)); err != nil {
// Only log cleanup failures, don't fail the test
t.Logf("Warning: Failed to cleanup bucket %s: %v", bucketName, err)
}
// Increased delay between operation sequences to reduce server load and improve stability
time.Sleep(100 * time.Millisecond)
}
}(i)
}
wg.Wait()
close(errors)
// Collect and analyze errors - with retry logic, we should see very few errors
var errorList []error
for err := range errors {
errorList = append(errorList, err)
}
totalOperations := numGoroutines * numOperationsPerGoroutine
// Report results
if len(errorList) == 0 {
t.Logf("All %d concurrent operations completed successfully with retry mechanisms!", totalOperations)
} else {
t.Logf("Concurrent operations summary:")
t.Logf(" Total operations: %d", totalOperations)
t.Logf(" Failed operations: %d (%.1f%% error rate)", len(errorList), float64(len(errorList))/float64(totalOperations)*100)
// Log first few errors for debugging
for i, err := range errorList {
if i >= 3 { // Limit to first 3 errors
t.Logf(" ... and %d more errors", len(errorList)-3)
break
}
t.Logf(" Error %d: %v", i+1, err)
}
}
// With proper retry mechanisms, we should expect near-zero failures
// Any remaining errors likely indicate real concurrency issues or system problems
if len(errorList) > 0 {
t.Errorf("%d operation(s) failed even after retry mechanisms (%.1f%% failure rate). This indicates potential system issues or race conditions that need investigation.",
len(errorList), float64(len(errorList))/float64(totalOperations)*100)
}
})
}
// TestS3IAMPerformanceTests tests IAM performance characteristics
func TestS3IAMPerformanceTests(t *testing.T) {
// Skip if not in performance test mode
if os.Getenv("ENABLE_PERFORMANCE_TESTS") != "true" {
t.Skip("Performance tests not enabled. Set ENABLE_PERFORMANCE_TESTS=true")
}
framework := NewS3IAMTestFramework(t)
defer framework.Cleanup()
t.Run("authentication_performance", func(t *testing.T) {
// Test authentication performance
const numRequests = 100
client, err := framework.CreateS3ClientWithJWT("perf-user", "TestAdminRole")
require.NoError(t, err)
bucketName := "test-auth-performance"
err = framework.CreateBucket(client, bucketName)
require.NoError(t, err)
defer func() {
_, err := client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(t, err)
}()
start := time.Now()
for i := 0; i < numRequests; i++ {
_, err := client.ListBuckets(&s3.ListBucketsInput{})
require.NoError(t, err)
}
duration := time.Since(start)
avgLatency := duration / numRequests
t.Logf("Authentication performance: %d requests in %v (avg: %v per request)",
numRequests, duration, avgLatency)
// Performance assertion - should be under 100ms per request on average
assert.Less(t, avgLatency, 100*time.Millisecond,
"Average authentication latency should be under 100ms")
})
t.Run("authorization_performance", func(t *testing.T) {
// Test authorization performance with different policy complexities
const numRequests = 50
client, err := framework.CreateS3ClientWithJWT("perf-user", "TestAdminRole")
require.NoError(t, err)
bucketName := "test-authz-performance"
err = framework.CreateBucket(client, bucketName)
require.NoError(t, err)
defer func() {
_, err := client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(t, err)
}()
start := time.Now()
for i := 0; i < numRequests; i++ {
objectKey := fmt.Sprintf("perf-object-%d.txt", i)
err := framework.PutTestObject(client, bucketName, objectKey, "performance test content")
require.NoError(t, err)
_, err = framework.GetTestObject(client, bucketName, objectKey)
require.NoError(t, err)
err = framework.DeleteTestObject(client, bucketName, objectKey)
require.NoError(t, err)
}
duration := time.Since(start)
avgLatency := duration / (numRequests * 3) // 3 operations per iteration
t.Logf("Authorization performance: %d operations in %v (avg: %v per operation)",
numRequests*3, duration, avgLatency)
// Performance assertion - should be under 50ms per operation on average
assert.Less(t, avgLatency, 50*time.Millisecond,
"Average authorization latency should be under 50ms")
})
}
// BenchmarkS3IAMAuthentication benchmarks JWT authentication
func BenchmarkS3IAMAuthentication(b *testing.B) {
if os.Getenv("ENABLE_PERFORMANCE_TESTS") != "true" {
b.Skip("Performance tests not enabled. Set ENABLE_PERFORMANCE_TESTS=true")
}
framework := NewS3IAMTestFramework(&testing.T{})
defer framework.Cleanup()
client, err := framework.CreateS3ClientWithJWT("bench-user", "TestAdminRole")
require.NoError(b, err)
bucketName := "test-bench-auth"
err = framework.CreateBucket(client, bucketName)
require.NoError(b, err)
defer func() {
_, err := client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(b, err)
}()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_, err := client.ListBuckets(&s3.ListBucketsInput{})
if err != nil {
b.Error(err)
}
}
})
}
// BenchmarkS3IAMAuthorization benchmarks policy evaluation
func BenchmarkS3IAMAuthorization(b *testing.B) {
if os.Getenv("ENABLE_PERFORMANCE_TESTS") != "true" {
b.Skip("Performance tests not enabled. Set ENABLE_PERFORMANCE_TESTS=true")
}
framework := NewS3IAMTestFramework(&testing.T{})
defer framework.Cleanup()
client, err := framework.CreateS3ClientWithJWT("bench-user", "TestAdminRole")
require.NoError(b, err)
bucketName := "test-bench-authz"
err = framework.CreateBucket(client, bucketName)
require.NoError(b, err)
defer func() {
_, err := client.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String(bucketName),
})
require.NoError(b, err)
}()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
objectKey := fmt.Sprintf("bench-object-%d.txt", i)
err := framework.PutTestObject(client, bucketName, objectKey, "benchmark content")
if err != nil {
b.Error(err)
}
i++
}
})
}