コード例 #1
0
ファイル: s3_compatible_test.go プロジェクト: kalambet/s3cli
			configurations...,
		)
		DescribeTable("Invoking `s3cli delete` on a non-existent-key does not fail",
			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())
		})
コード例 #2
0
			s3CLIPath := os.Getenv("S3_CLI_PATH")
			Expect(s3CLIPath).ToNot(BeEmpty(), "S3_CLI_PATH must be set")

			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())