Browse Source

Fix S3 client credentials to use environment variables

The test was using hardcoded credentials "any"/"any" but the Makefile
sets AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY to "some_access_key1"/
"some_secret_key1". Updated getS3Client() to read from environment
variables with fallback to "any"/"any" for manual testing.
pull/7890/head
Chris Lu 3 days ago
parent
commit
67f1ad7db0
  1. 14
      test/s3/sse/s3_volume_encryption_test.go

14
test/s3/sse/s3_volume_encryption_test.go

@ -8,6 +8,7 @@ import (
"context"
"fmt"
"io"
"os"
"strings"
"testing"
"time"
@ -399,12 +400,23 @@ func TestS3VolumeEncryptionCopy(t *testing.T) {
// Helper functions
func getS3Client(t *testing.T) *s3.S3 {
// Use credentials from environment if available, otherwise use defaults
// This allows tests to work with the Makefile which sets AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY
accessKey := "any"
secretKey := "any"
if envAccessKey := os.Getenv("AWS_ACCESS_KEY_ID"); envAccessKey != "" {
accessKey = envAccessKey
}
if envSecretKey := os.Getenv("AWS_SECRET_ACCESS_KEY"); envSecretKey != "" {
secretKey = envSecretKey
}
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-1"),
Endpoint: aws.String("http://localhost:8333"),
DisableSSL: aws.Bool(true),
S3ForcePathStyle: aws.Bool(true),
Credentials: credentials.NewStaticCredentials("any", "any", ""),
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
})
if err != nil {
t.Fatalf("Failed to create session: %v", err)

Loading…
Cancel
Save