Beispiel #1
0
			func(cfg *config.S3Cli) { integration.AssertDeleteNonexistentWorks(s3CLIPath, cfg) },
			configurations...,
		)

		It("fails with a config that specifies signature version 4", func() {
			cfg := &config.S3Cli{
				SignatureVersion: 4,
				AccessKeyID:      accessKeyID,
				SecretAccessKey:  secretAccessKey,
				BucketName:       bucketName,
				Host:             s3Host,
			}
			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())

			s3CLISession, err = integration.RunS3CLI(s3CLIPath, configPath, "delete", s3Filename)
			Expect(err).ToNot(HaveOccurred())
			Expect(s3CLISession.ExitCode()).ToNot(BeZero())
		})
	})
})
				Body:   strings.NewReader(s3FileContents),
				Bucket: &bucketName,
				Key:    &s3Filename,
				ACL:    aws.String(s3.ObjectCannedACLPublicRead),
			})
			Expect(err).ToNot(HaveOccurred())

			cfg := &config.S3Cli{
				BucketName: bucketName,
				Region:     region,
			}

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

			s3CLISession, err := integration.RunS3CLI(s3CLIPath, configPath, "get", s3Filename, "public-file")
			Expect(err).ToNot(HaveOccurred())

			defer func() { _ = os.Remove("public-file") }()
			Expect(s3CLISession.ExitCode()).To(BeZero())

			gottenBytes, err := ioutil.ReadFile("public-file")
			Expect(err).ToNot(HaveOccurred())
			Expect(string(gottenBytes)).To(Equal(s3FileContents))

			s3CLISession, err = integration.RunS3CLI(s3CLIPath, configPath, "exists", s3Filename)
			Expect(err).ToNot(HaveOccurred())
			Expect(s3CLISession.ExitCode()).To(BeZero())
			Expect(s3CLISession.Err.Contents()).To(MatchRegexp("File '.*' exists in bucket '.*'"))
		})
	})