diff --git a/concourse/tasks/custom-broker-acceptance-tests-run.yml b/concourse/tasks/custom-broker-acceptance-tests-run.yml index 67ff72e428..d2297e1d5c 100644 --- a/concourse/tasks/custom-broker-acceptance-tests-run.yml +++ b/concourse/tasks/custom-broker-acceptance-tests-run.yml @@ -25,5 +25,5 @@ run: echo "WARNING: The custom acceptance tests have been disabled. Unset DISABLE_CUSTOM_ACCEPTANCE_TESTS when uploading the pipelines to enable them. You can still hijack this container to run them manually, but you must update the admin user in ./test-config/config.json." else cd paas-cf/platform-tests/broker-acceptance - go run github.com/onsi/ginkgo/v2/ginkgo -procs 4 --compilers 4 -timeout=60m --poll-progress-after=120s --poll-progress-interval=30s + go run github.com/onsi/ginkgo/v2/ginkgo --focus=S3 -procs 4 --compilers 4 -timeout=60m --poll-progress-after=120s --poll-progress-interval=30s fi diff --git a/platform-tests/broker-acceptance/s3_broker_test.go b/platform-tests/broker-acceptance/s3_broker_test.go index d0a001bf5b..416cd306b9 100644 --- a/platform-tests/broker-acceptance/s3_broker_test.go +++ b/platform-tests/broker-acceptance/s3_broker_test.go @@ -1,14 +1,15 @@ package broker_acceptance_test import ( + "encoding/json" "io/ioutil" "time" -// "github.com/aws/aws-sdk-go/aws/credentials" -// -// "github.com/aws/aws-sdk-go/aws" -// "github.com/aws/aws-sdk-go/aws/session" -// "github.com/aws/aws-sdk-go/service/s3" + "github.com/aws/aws-sdk-go/aws/credentials" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/s3" "github.com/cloudfoundry/cf-test-helpers/cf" "github.com/cloudfoundry/cf-test-helpers/generator" @@ -25,6 +26,13 @@ var _ = Describe("S3 broker", func() { testPlanName = "default" ) + type ServiceKeyCredentials struct { + BucketName string `json:"bucket_name"` + AWSAccessKeyID string `json:"aws_access_key_id"` + AWSSecretAccessKey string `json:"aws_secret_access_key"` + AWSRegion string `json:"aws_region"` + } + It("is registered in the marketplace", func() { plans := cf.Cf("marketplace").Wait(testConfig.DefaultTimeoutDuration()) Expect(plans).To(Exit(0)) @@ -94,6 +102,8 @@ var _ = Describe("S3 broker", func() { }) It("is externally accessible from an allow_external_access service key", func() { + var serviceKeyCredentials ServiceKeyCredentials + var s3Client *s3.S3 serviceKeyName := generator.PrefixedRandomName(testConfig.GetNamePrefix(), "test-service-key") By("creating the service key: "+serviceKeyName, func() { @@ -117,16 +127,32 @@ var _ = Describe("S3 broker", func() { serviceKeyName, ) Expect(cfSess.Wait(testConfig.DefaultTimeoutDuration())).To(Exit(0)) - Expect(cfSess.Out).To(Say("foo")) + + err := json.Unmarshal(cfSess.Out.Contents(), &serviceKeyCredentials) + Expect(err).ToNot(HaveOccurred()) + + Expect(serviceKeyCredentials.BucketName).ToNot(Equal("")) + Expect(serviceKeyCredentials.AWSAccessKeyID).ToNot(Equal("")) + Expect(serviceKeyCredentials.AWSSecretAccessKey).ToNot(Equal("")) + Expect(serviceKeyCredentials.AWSRegion).ToNot(Equal("")) + + sess := session.Must(session.NewSession(&aws.Config{ + Region: aws.String(serviceKeyCredentials.AWSRegion), + Credentials: credentials.NewStaticCredentials( + serviceKeyCredentials.AWSAccessKeyID, + serviceKeyCredentials.AWSSecretAccessKey, + "", + ), + })) + s3Client = s3.New(sess) }) -// By("Accessing the app from the test host", func() { -// sess := session.Must(session.NewSession(&aws.Config{ -// Region: aws.String(vcapService.AWSRegion), -// Credentials: credentials.NewStaticCredentials(vcapService.AWSAccessKeyID, vcapService.AWSSecretAccessKey, ""), -// })) -// s3Client := s3.New(sess) -// }) + By("Accessing the bucket from the test host", func() { + _, err := s3Client.ListObjects(&s3.ListObjectsInput{ + Bucket: aws.String(serviceKeyCredentials.BucketName), + }) + Expect(err).ToNot(HaveOccurred()) + }) }) })