bucketName := os.Getenv("BUCKET_NAME")
			Expect(bucketName).ToNot(BeEmpty(), "BUCKET_NAME must be set")

			region := os.Getenv("REGION")
			Expect(region).ToNot(BeEmpty(), "REGION must be set")

			cfg := &config.S3Cli{
				SignatureVersion:  4,
				CredentialsSource: "static",
				AccessKeyID:       accessKeyID,
				SecretAccessKey:   secretAccessKey,
				BucketName:        bucketName,
				Region:            region,
				Host:              "s3-external-1.amazonaws.com",
			}
			s3Filename := integration.GenerateRandomString()

			configPath := integration.MakeConfigFile(cfg)
			defer func() { _ = os.Remove(configPath) }()

			contentFile := integration.MakeContentFile("test")
			defer func() { _ = os.Remove(contentFile) }()

			s3CLISession, err := integration.RunS3CLI(s3CLIPath, configPath, "put", contentFile, s3Filename)
			Expect(err).ToNot(HaveOccurred())
			Expect(s3CLISession.ExitCode()).ToNot(BeZero())
			Expect(s3CLISession.Err.Contents()).To(ContainSubstring("AuthorizationHeaderMalformed"))

			s3CLISession, err = integration.RunS3CLI(s3CLIPath, configPath, "delete", s3Filename)
			Expect(err).ToNot(HaveOccurred())
			Expect(s3CLISession.ExitCode()).ToNot(BeZero())
	"github.com/onsi/gomega/gexec"
	"github.com/pivotal-golang/s3cli/integration"

	"testing"
)

func TestIntegration(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Integration Suite")
}

var s3CLIPath string
var largeContent string

var _ = BeforeSuite(func() {
	// Running the IAM tests within an AWS Lambda environment
	// require a pre-compiled binary
	s3CLIPath = os.Getenv("S3_CLI_PATH")
	largeContent = integration.GenerateRandomString(1024 * 1024 * 6)

	if len(s3CLIPath) == 0 {
		var err error
		s3CLIPath, err = gexec.Build("github.com/pivotal-golang/s3cli")
		Expect(err).ShouldNot(HaveOccurred())
	}
})

var _ = AfterSuite(func() {
	gexec.CleanupBuildArtifacts()
})
var _ = Describe("Testing gets against a public AWS S3 bucket", func() {
	Context("with PUBLIC READ ONLY (no creds) configuration", func() {
		It("can successfully get a publicly readable file", func() {
			accessKeyID := os.Getenv("ACCESS_KEY_ID")
			Expect(accessKeyID).ToNot(BeEmpty(), "ACCESS_KEY_ID must be set")

			secretAccessKey := os.Getenv("SECRET_ACCESS_KEY")
			Expect(secretAccessKey).ToNot(BeEmpty(), "SECRET_ACCESS_KEY must be set")

			bucketName := os.Getenv("BUCKET_NAME")
			Expect(bucketName).ToNot(BeEmpty(), "BUCKET_NAME must be set")

			region := os.Getenv("REGION")
			Expect(region).ToNot(BeEmpty(), "REGION must be set")

			s3Filename := integration.GenerateRandomString()
			s3FileContents := integration.GenerateRandomString()

			s3Client := s3.New(session.New(&aws.Config{
				Credentials: credentials.NewStaticCredentials(accessKeyID, secretAccessKey, ""),
				Region:      aws.String(region),
			}))

			_, err := s3Client.PutObject(&s3.PutObjectInput{
				Body:   strings.NewReader(s3FileContents),
				Bucket: &bucketName,
				Key:    &s3Filename,
				ACL:    aws.String(s3.ObjectCannedACLPublicRead),
			})
			Expect(err).ToNot(HaveOccurred())