Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
risicle committed Oct 16, 2023
1 parent 1ad5c87 commit 6697c6f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion concourse/tasks/custom-broker-acceptance-tests-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
52 changes: 39 additions & 13 deletions platform-tests/broker-acceptance/s3_broker_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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))
Expand Down Expand Up @@ -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() {
Expand All @@ -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())
})
})
})

Expand Down

0 comments on commit 6697c6f

Please sign in to comment.