1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-23 03:33:28 +00:00

Switch to using the dep tool and update all the dependencies

This commit is contained in:
Nick Craig-Wood
2017-05-11 15:39:54 +01:00
parent 5135ff73cb
commit 98c2d2c41b
5321 changed files with 4483201 additions and 5922 deletions

View File

@@ -0,0 +1,124 @@
// +build integration
// Package s3_test runs integration tests for S3
package s3_test
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration"
"github.com/aws/aws-sdk-go/service/s3"
)
var bucketName *string
var svc *s3.S3
func TestMain(m *testing.M) {
setup()
defer teardown() // only called if we panic
result := m.Run()
teardown()
os.Exit(result)
}
// Create a bucket for testing
func setup() {
svc = s3.New(integration.Session)
bucketName = aws.String(
fmt.Sprintf("aws-sdk-go-integration-%d-%s", time.Now().Unix(), integration.UniqueID()))
for i := 0; i < 10; i++ {
_, err := svc.CreateBucket(&s3.CreateBucketInput{Bucket: bucketName})
if err == nil {
break
}
}
for {
_, err := svc.HeadBucket(&s3.HeadBucketInput{Bucket: bucketName})
if err == nil {
break
}
time.Sleep(1 * time.Second)
}
}
// Delete the bucket
func teardown() {
resp, _ := svc.ListObjects(&s3.ListObjectsInput{Bucket: bucketName})
for _, o := range resp.Contents {
svc.DeleteObject(&s3.DeleteObjectInput{Bucket: bucketName, Key: o.Key})
}
svc.DeleteBucket(&s3.DeleteBucketInput{Bucket: bucketName})
}
func TestWriteToObject(t *testing.T) {
_, err := svc.PutObject(&s3.PutObjectInput{
Bucket: bucketName,
Key: aws.String("key name"),
Body: bytes.NewReader([]byte("hello world")),
})
assert.NoError(t, err)
resp, err := svc.GetObject(&s3.GetObjectInput{
Bucket: bucketName,
Key: aws.String("key name"),
})
assert.NoError(t, err)
b, _ := ioutil.ReadAll(resp.Body)
assert.Equal(t, []byte("hello world"), b)
}
func TestPresignedGetPut(t *testing.T) {
putreq, _ := svc.PutObjectRequest(&s3.PutObjectInput{
Bucket: bucketName,
Key: aws.String("presigned-key"),
})
var err error
// Presign a PUT request
var puturl string
puturl, err = putreq.Presign(300 * time.Second)
assert.NoError(t, err)
// PUT to the presigned URL with a body
var puthttpreq *http.Request
buf := bytes.NewReader([]byte("hello world"))
puthttpreq, err = http.NewRequest("PUT", puturl, buf)
assert.NoError(t, err)
var putresp *http.Response
putresp, err = http.DefaultClient.Do(puthttpreq)
assert.NoError(t, err)
assert.Equal(t, 200, putresp.StatusCode)
// Presign a GET on the same URL
getreq, _ := svc.GetObjectRequest(&s3.GetObjectInput{
Bucket: bucketName,
Key: aws.String("presigned-key"),
})
var geturl string
geturl, err = getreq.Presign(300 * time.Second)
assert.NoError(t, err)
// Get the body
var getresp *http.Response
getresp, err = http.Get(geturl)
assert.NoError(t, err)
var b []byte
defer getresp.Body.Close()
b, err = ioutil.ReadAll(getresp.Body)
assert.Equal(t, "hello world", string(b))
}

View File

@@ -0,0 +1,29 @@
// +build integration
//Package s3crypto provides gucumber integration tests support.
package s3crypto
import (
"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/service/s3/s3crypto"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@s3crypto", func() {
sess := session.New((&aws.Config{
Region: aws.String("us-west-2"),
}))
encryptionClient := s3crypto.NewEncryptionClient(sess, nil, func(c *s3crypto.EncryptionClient) {
})
gucumber.World["encryptionClient"] = encryptionClient
decryptionClient := s3crypto.NewDecryptionClient(sess)
gucumber.World["decryptionClient"] = decryptionClient
gucumber.World["client"] = s3.New(sess)
})
}

View File

@@ -0,0 +1,33 @@
# language: en
@s3crypto @client
Feature: S3 Integration Crypto Tests
Scenario: Uploading Go's SDK fixtures
When I get all fixtures for "aes_gcm" from "aws-s3-shared-tests"
Then I encrypt each fixture with "kms" "AWS_SDK_TEST_ALIAS" "us-west-2" and "aes_gcm"
And upload "Go" data with folder "version_2"
Scenario: Uploading Go's SDK fixtures
When I get all fixtures for "aes_cbc" from "aws-s3-shared-tests"
Then I encrypt each fixture with "kms" "AWS_SDK_TEST_ALIAS" "us-west-2" and "aes_cbc"
And upload "Go" data with folder "version_2"
Scenario: Get all plaintext fixtures for symmetric masterkey aes gcm
When I get all fixtures for "aes_gcm" from "aws-s3-shared-tests"
Then I decrypt each fixture against "Go" "version_2"
And I compare the decrypted ciphertext to the plaintext
Scenario: Get all plaintext fixtures for symmetric masterkey aes cbc
When I get all fixtures for "aes_cbc" from "aws-s3-shared-tests"
Then I decrypt each fixture against "Go" "version_2"
And I compare the decrypted ciphertext to the plaintext
Scenario: Get all plaintext fixtures for symmetric masterkey aes gcm
When I get all fixtures for "aes_gcm" from "aws-s3-shared-tests"
Then I decrypt each fixture against "Java" "version_2"
And I compare the decrypted ciphertext to the plaintext
Scenario: Get all plaintext fixtures for symmetric masterkey aes cbc
When I get all fixtures for "aes_cbc" from "aws-s3-shared-tests"
Then I decrypt each fixture against "Java" "version_2"
And I compare the decrypted ciphertext to the plaintext

View File

@@ -0,0 +1,190 @@
// +build integration
// Package s3crypto contains shared step definitions that are used across integration tests
package s3crypto
import (
"bytes"
"encoding/base64"
"errors"
"io/ioutil"
"strings"
"github.com/gucumber/gucumber"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3crypto"
)
func init() {
gucumber.When(`^I get all fixtures for "(.+?)" from "(.+?)"$`,
func(cekAlg, bucket string) {
prefix := "plaintext_test_case_"
baseFolder := "crypto_tests/" + cekAlg
s3Client := gucumber.World["client"].(*s3.S3)
out, err := s3Client.ListObjects(&s3.ListObjectsInput{
Bucket: aws.String(bucket),
Prefix: aws.String(baseFolder + "/" + prefix),
})
assert.NoError(gucumber.T, err)
plaintexts := make(map[string][]byte)
for _, obj := range out.Contents {
plaintextKey := obj.Key
ptObj, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: plaintextKey,
})
assert.NoError(gucumber.T, err)
caseKey := strings.TrimPrefix(*plaintextKey, baseFolder+"/"+prefix)
plaintext, err := ioutil.ReadAll(ptObj.Body)
assert.NoError(gucumber.T, err)
plaintexts[caseKey] = plaintext
}
gucumber.World["baseFolder"] = baseFolder
gucumber.World["bucket"] = bucket
gucumber.World["plaintexts"] = plaintexts
})
gucumber.Then(`^I decrypt each fixture against "(.+?)" "(.+?)"$`, func(lang, version string) {
plaintexts := gucumber.World["plaintexts"].(map[string][]byte)
baseFolder := gucumber.World["baseFolder"].(string)
bucket := gucumber.World["bucket"].(string)
prefix := "ciphertext_test_case_"
s3Client := gucumber.World["client"].(*s3.S3)
s3CryptoClient := gucumber.World["decryptionClient"].(*s3crypto.DecryptionClient)
language := "language_" + lang
ciphertexts := make(map[string][]byte)
for caseKey := range plaintexts {
cipherKey := baseFolder + "/" + version + "/" + language + "/" + prefix + caseKey
// To get metadata for encryption key
ctObj, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: &cipherKey,
})
if err != nil {
continue
}
// We don't support wrap, so skip it
if ctObj.Metadata["X-Amz-Wrap-Alg"] == nil || *ctObj.Metadata["X-Amz-Wrap-Alg"] != "kms" {
continue
}
ctObj, err = s3CryptoClient.GetObject(&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: &cipherKey,
},
)
assert.NoError(gucumber.T, err)
ciphertext, err := ioutil.ReadAll(ctObj.Body)
assert.NoError(gucumber.T, err)
ciphertexts[caseKey] = ciphertext
}
gucumber.World["decrypted"] = ciphertexts
})
gucumber.And(`^I compare the decrypted ciphertext to the plaintext$`, func() {
plaintexts := gucumber.World["plaintexts"].(map[string][]byte)
ciphertexts := gucumber.World["decrypted"].(map[string][]byte)
for caseKey, ciphertext := range ciphertexts {
assert.Equal(gucumber.T, len(plaintexts[caseKey]), len(ciphertext))
assert.True(gucumber.T, bytes.Equal(plaintexts[caseKey], ciphertext))
}
})
gucumber.Then(`^I encrypt each fixture with "(.+?)" "(.+?)" "(.+?)" and "(.+?)"$`, func(kek, v1, v2, cek string) {
var handler s3crypto.CipherDataGenerator
var builder s3crypto.ContentCipherBuilder
switch kek {
case "kms":
arn, err := getAliasInformation(v1, v2)
assert.Nil(gucumber.T, err)
b64Arn := base64.StdEncoding.EncodeToString([]byte(arn))
assert.Nil(gucumber.T, err)
gucumber.World["Masterkey"] = b64Arn
handler = s3crypto.NewKMSKeyGenerator(kms.New(session.New(&aws.Config{
Region: &v2,
})), arn)
assert.Nil(gucumber.T, err)
default:
gucumber.T.Skip()
}
switch cek {
case "aes_gcm":
builder = s3crypto.AESGCMContentCipherBuilder(handler)
case "aes_cbc":
builder = s3crypto.AESCBCContentCipherBuilder(handler, s3crypto.AESCBCPadder)
default:
gucumber.T.Skip()
}
sess := session.New(&aws.Config{
Region: aws.String("us-west-2"),
})
c := s3crypto.NewEncryptionClient(sess, builder, func(c *s3crypto.EncryptionClient) {
})
gucumber.World["encryptionClient"] = c
gucumber.World["cek"] = cek
})
gucumber.And(`^upload "(.+?)" data with folder "(.+?)"$`, func(language, folder string) {
c := gucumber.World["encryptionClient"].(*s3crypto.EncryptionClient)
cek := gucumber.World["cek"].(string)
bucket := gucumber.World["bucket"].(string)
plaintexts := gucumber.World["plaintexts"].(map[string][]byte)
key := gucumber.World["Masterkey"].(string)
for caseKey, plaintext := range plaintexts {
input := &s3.PutObjectInput{
Bucket: &bucket,
Key: aws.String("crypto_tests/" + cek + "/" + folder + "/language_" + language + "/ciphertext_test_case_" + caseKey),
Body: bytes.NewReader(plaintext),
Metadata: map[string]*string{
"Masterkey": &key,
},
}
_, err := c.PutObject(input)
assert.Nil(gucumber.T, err)
}
})
}
func getAliasInformation(alias, region string) (string, error) {
arn := ""
svc := kms.New(session.New(&aws.Config{
Region: &region,
}))
truncated := true
var marker *string
for truncated {
out, err := svc.ListAliases(&kms.ListAliasesInput{
Marker: marker,
})
if err != nil {
return arn, err
}
for _, aliasEntry := range out.Aliases {
if *aliasEntry.AliasName == "alias/"+alias {
return *aliasEntry.AliasArn, nil
}
}
truncated = *out.Truncated
marker = out.NextMarker
}
return "", errors.New("The alias " + alias + " does not exist in your account. Please add the proper alias to a key")
}

View File

@@ -0,0 +1,27 @@
// +build integration
package s3manager
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)
func TestGetBucketRegion(t *testing.T) {
expectRegion := aws.StringValue(integration.Session.Config.Region)
ctx := aws.BackgroundContext()
region, err := s3manager.GetBucketRegion(ctx, integration.Session,
aws.StringValue(bucketName), expectRegion)
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
if e, a := expectRegion, region; e != a {
t.Errorf("expect %s bucket region, got %s", e, a)
}
}

View File

@@ -0,0 +1,210 @@
// +build integration
// Package s3manager provides integration tests for the service/s3/s3manager package
package s3manager
import (
"bytes"
"crypto/md5"
"fmt"
"io"
"os"
"regexp"
"strings"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/awstesting/integration"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)
var integBuf12MB = make([]byte, 1024*1024*12)
var integMD512MB = fmt.Sprintf("%x", md5.Sum(integBuf12MB))
var bucketName *string
func TestMain(m *testing.M) {
if err := setup(); err != nil {
panic(fmt.Sprintf("failed to setup integration test, %v", err))
}
var result int
defer func() {
if err := teardown(); err != nil {
fmt.Fprintf(os.Stderr, "teardown failed, %v", err)
}
if r := recover(); r != nil {
fmt.Println("S3Manager integration test hit a panic,", r)
result = 1
}
os.Exit(result)
}()
result = m.Run()
}
func setup() error {
svc := s3.New(integration.Session)
// Create a bucket for testing
bucketName = aws.String(
fmt.Sprintf("aws-sdk-go-integration-%d-%s", time.Now().Unix(), integration.UniqueID()))
_, err := svc.CreateBucket(&s3.CreateBucketInput{Bucket: bucketName})
if err != nil {
return fmt.Errorf("failed to create bucket %q, %v", *bucketName, err)
}
err = svc.WaitUntilBucketExists(&s3.HeadBucketInput{Bucket: bucketName})
if err != nil {
return fmt.Errorf("failed to wait for bucket %q to exist, %v", bucketName, err)
}
return nil
}
// Delete the bucket
func teardown() error {
svc := s3.New(integration.Session)
objs, err := svc.ListObjects(&s3.ListObjectsInput{Bucket: bucketName})
if err != nil {
return fmt.Errorf("failed to list bucket %q objects, %v", bucketName, err)
}
for _, o := range objs.Contents {
svc.DeleteObject(&s3.DeleteObjectInput{Bucket: bucketName, Key: o.Key})
}
uploads, err := svc.ListMultipartUploads(&s3.ListMultipartUploadsInput{Bucket: bucketName})
if err != nil {
return fmt.Errorf("failed to list bucket %q multipart objects, %v", bucketName, err)
}
for _, u := range uploads.Uploads {
svc.AbortMultipartUpload(&s3.AbortMultipartUploadInput{
Bucket: bucketName,
Key: u.Key,
UploadId: u.UploadId,
})
}
_, err = svc.DeleteBucket(&s3.DeleteBucketInput{Bucket: bucketName})
if err != nil {
return fmt.Errorf("failed to delete bucket %q, %v", bucketName, err)
}
return nil
}
type dlwriter struct {
buf []byte
}
func newDLWriter(size int) *dlwriter {
return &dlwriter{buf: make([]byte, size)}
}
func (d dlwriter) WriteAt(p []byte, pos int64) (n int, err error) {
if pos > int64(len(d.buf)) {
return 0, io.EOF
}
written := 0
for i, b := range p {
if i >= len(d.buf) {
break
}
d.buf[pos+int64(i)] = b
written++
}
return written, nil
}
func validate(t *testing.T, key string, md5value string) {
mgr := s3manager.NewDownloader(integration.Session)
params := &s3.GetObjectInput{Bucket: bucketName, Key: &key}
w := newDLWriter(1024 * 1024 * 20)
n, err := mgr.Download(w, params)
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
if e, a := md5value, fmt.Sprintf("%x", md5.Sum(w.buf[0:n])); e != a {
t.Errorf("expect %s md5 value, got %s", e, a)
}
}
func TestUploadConcurrently(t *testing.T) {
key := "12mb-1"
mgr := s3manager.NewUploader(integration.Session)
out, err := mgr.Upload(&s3manager.UploadInput{
Bucket: bucketName,
Key: &key,
Body: bytes.NewReader(integBuf12MB),
})
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
if len(out.UploadID) == 0 {
t.Errorf("expect upload ID but was empty")
}
re := regexp.MustCompile(`^https?://.+/` + key + `$`)
if e, a := re.String(), out.Location; !re.MatchString(a) {
t.Errorf("expect %s to match URL regexp %q, did not", e, a)
}
validate(t, key, integMD512MB)
}
func TestUploadFailCleanup(t *testing.T) {
svc := s3.New(integration.Session)
// Break checksum on 2nd part so it fails
part := 0
svc.Handlers.Build.PushBack(func(r *request.Request) {
if r.Operation.Name == "UploadPart" {
if part == 1 {
r.HTTPRequest.Header.Set("X-Amz-Content-Sha256", "000")
}
part++
}
})
key := "12mb-leave"
mgr := s3manager.NewUploaderWithClient(svc, func(u *s3manager.Uploader) {
u.LeavePartsOnError = false
})
_, err := mgr.Upload(&s3manager.UploadInput{
Bucket: bucketName,
Key: &key,
Body: bytes.NewReader(integBuf12MB),
})
if err == nil {
t.Fatalf("expect error, but did not get one")
}
aerr := err.(awserr.Error)
if e, a := "MissingRegion", aerr.Code(); strings.Contains(a, e) {
t.Errorf("expect %q to not be in error code %q", e, a)
}
uploadID := ""
merr := err.(s3manager.MultiUploadFailure)
if uploadID = merr.UploadID(); len(uploadID) == 0 {
t.Errorf("expect upload ID to not be empty, but was")
}
_, err = svc.ListParts(&s3.ListPartsInput{
Bucket: bucketName, Key: &key, UploadId: &uploadID,
})
if err == nil {
t.Errorf("expect error for list parts, but got none")
}
}

View File

@@ -0,0 +1 @@
package s3manager

View File

@@ -0,0 +1 @@
package s3

View File

@@ -0,0 +1,44 @@
// +build integration
// Package integration performs initialization and validation for integration
// tests.
package integration
import (
"crypto/rand"
"fmt"
"io"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
)
// Session is a shared session for all integration tests to use.
var Session = session.Must(session.NewSession())
func init() {
logLevel := Session.Config.LogLevel
if os.Getenv("DEBUG") != "" {
logLevel = aws.LogLevel(aws.LogDebug)
}
if os.Getenv("DEBUG_SIGNING") != "" {
logLevel = aws.LogLevel(aws.LogDebugWithSigning)
}
if os.Getenv("DEBUG_BODY") != "" {
logLevel = aws.LogLevel(aws.LogDebugWithSigning | aws.LogDebugWithHTTPBody)
}
Session.Config.LogLevel = logLevel
if aws.StringValue(Session.Config.Region) == "" {
panic("AWS_REGION must be configured to run integration tests")
}
}
// UniqueID returns a unique UUID-like identifier for use in generating
// resources for integration tests.
func UniqueID() string {
uuid := make([]byte, 16)
io.ReadFull(rand.Reader, uuid)
return fmt.Sprintf("%x", uuid)
}

View File

@@ -0,0 +1,14 @@
#language en
@acm @client
Feature: AWS Certificate Manager
Scenario: Making a request
When I call the "ListCertificates" API
Then the request should be successful
Scenario: Handling errors
When I attempt to call the "GetCertificate" API with:
| CertificateArn | arn:aws:acm:region:123456789012:certificate/12345678-1234-1234-1234-123456789012 |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message not be empty

View File

@@ -0,0 +1,16 @@
// +build integration
//Package acm provides gucumber integration tests support.
package acm
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/acm"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@acm", func() {
gucumber.World["client"] = acm.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@apigateway @client
Feature: Amazon API Gateway
Scenario: Making a request
When I call the "GetAccountRequest" API
Then the request should be successful
Scenario: Handing errors
When I attempt to call the "GetRestApi" API with:
| RestApiId | api123 |
Then I expect the response error code to be "NotFoundException"
And I expect the response error message to include:
"""
Invalid REST API identifier specified
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package apigateway provides gucumber integration tests support.
package apigateway
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@apigateway", func() {
gucumber.World["client"] = apigateway.New(smoke.Session)
})
}

View File

@@ -0,0 +1,8 @@
#language en
@applicationdiscoveryservice @client
Feature: AWS Application Discovery Service
Scenario: Making a request
When I call the "DescribeAgents" API
Then the request should be successful

View File

@@ -0,0 +1,19 @@
// +build integration
//Package applicationdiscoveryservice provides gucumber integration tests support.
package applicationdiscoveryservice
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/applicationdiscoveryservice"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@applicationdiscoveryservice", func() {
gucumber.World["client"] = applicationdiscoveryservice.New(
smoke.Session, &aws.Config{Region: aws.String("us-west-2")},
)
})
}

View File

@@ -0,0 +1,18 @@
# language: en
@autoscaling @client
Feature: Auto Scaling
Scenario: Making a request
When I call the "DescribeScalingProcessTypes" API
Then the value at "Processes" should be a list
Scenario: Handing errors
When I attempt to call the "CreateLaunchConfiguration" API with:
| LaunchConfigurationName | |
| ImageId | ami-12345678 |
| InstanceType | m1.small |
Then I expect the response error code to be "InvalidParameter"
And I expect the response error message to include:
"""
LaunchConfigurationName
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package autoscaling provides gucumber integration tests support.
package autoscaling
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@autoscaling", func() {
gucumber.World["client"] = autoscaling.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudformation provides gucumber integration tests support.
package cloudformation
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudformation", func() {
gucumber.World["client"] = cloudformation.New(smoke.Session)
})
}

View File

@@ -0,0 +1,17 @@
# language: en
@cloudformation @client
Feature: AWS CloudFormation
Scenario: Making a request
When I call the "ListStacks" API
Then the value at "StackSummaries" should be a list
Scenario: Handling errors
When I attempt to call the "CreateStack" API with:
| StackName | fakestack |
| TemplateURL | http://s3.amazonaws.com/foo/bar |
Then I expect the response error code to be "ValidationError"
And I expect the response error message to include:
"""
TemplateURL must reference a valid S3 object to which you have access.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudfront provides gucumber integration tests support.
package cloudfront
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudfront", func() {
gucumber.World["client"] = cloudfront.New(smoke.Session)
})
}

View File

@@ -0,0 +1,17 @@
# language: en
@cloudfront @client
Feature: Amazon CloudFront
Scenario: Making a basic request
When I call the "ListDistributions" API with:
| MaxItems | 1 |
Then the value at "DistributionList.Items" should be a list
Scenario: Error handling
When I attempt to call the "GetDistribution" API with:
| Id | fake-id |
Then I expect the response error code to be "NoSuchDistribution"
And I expect the response error message to include:
"""
The specified distribution does not exist.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudhsm provides gucumber integration tests support.
package cloudhsm
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudhsm"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudhsm", func() {
gucumber.World["client"] = cloudhsm.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@cloudhsm @client
Feature: Amazon CloudHSM
Scenario: Making a request
When I call the "ListHapgs" API
Then the value at "HapgList" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeHapg" API with:
| HapgArn | bogus-arn |
Then I expect the response error code to be "ValidationException"
And I expect the response error message to include:
"""
Value 'bogus-arn' at 'hapgArn' failed to satisfy constraint
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudsearch provides gucumber integration tests support.
package cloudsearch
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudsearch"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudsearch", func() {
gucumber.World["client"] = cloudsearch.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@cloudsearch @client
Feature: Amazon CloudSearch
Scenario: Making a request
When I call the "DescribeDomains" API
Then the response should contain a "DomainStatusList"
Scenario: Handling errors
When I attempt to call the "DescribeIndexFields" API with:
| DomainName | fakedomain |
Then I expect the response error code to be "ResourceNotFound"
And I expect the response error message to include:
"""
Domain not found: fakedomain
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudtrail provides gucumber integration tests support.
package cloudtrail
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudtrail"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudtrail", func() {
gucumber.World["client"] = cloudtrail.New(smoke.Session)
})
}

View File

@@ -0,0 +1,12 @@
# language: en
@cloudtrail @client
Feature: AWS CloudTrail
Scenario: Making a request
When I call the "DescribeTrails" API
Then the request should be successful
Scenario: Handling errors
When I attempt to call the "DeleteTrail" API with:
| Name | faketrail |
Then I expect the response error code to be "TrailNotFoundException"

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudwatch provides gucumber integration tests support.
package cloudwatch
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudwatch", func() {
gucumber.World["client"] = cloudwatch.New(smoke.Session)
})
}

View File

@@ -0,0 +1,19 @@
# language: en
@cloudwatch @monitoring @client
Feature: Amazon CloudWatch
Scenario: Making a request
When I call the "ListMetrics" API with:
| Namespace | AWS/EC2 |
Then the value at "Metrics" should be a list
Scenario: Handling errors
When I attempt to call the "SetAlarmState" API with:
| AlarmName | abc |
| StateValue | mno |
| StateReason | xyz |
Then I expect the response error code to be "ValidationError"
And I expect the response error message to include:
"""
failed to satisfy constraint
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cloudwatchlogs provides gucumber integration tests support.
package cloudwatchlogs
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cloudwatchlogs", func() {
gucumber.World["client"] = cloudwatchlogs.New(smoke.Session)
})
}

View File

@@ -0,0 +1,17 @@
# language: en
@cloudwatchlogs @logs
Feature: Amazon CloudWatch Logs
Scenario: Making a request
When I call the "DescribeLogGroups" API
Then the value at "logGroups" should be a list
Scenario: Handling errors
When I attempt to call the "GetLogEvents" API with:
| logGroupName | fakegroup |
| logStreamName | fakestream |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
The specified log group does not exist.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package codecommit provides gucumber integration tests support.
package codecommit
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/codecommit"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@codecommit", func() {
gucumber.World["client"] = codecommit.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@codecommit @client
Feature: Amazon CodeCommit
Scenario: Making a request
When I call the "ListRepositories" API
Then the value at "repositories" should be a list
Scenario: Handling errors
When I attempt to call the "ListBranches" API with:
| repositoryName | fake-repo |
Then I expect the response error code to be "RepositoryDoesNotExistException"
And I expect the response error message to include:
"""
fake-repo does not exist
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package codedeploy provides gucumber integration tests support.
package codedeploy
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/codedeploy"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@codedeploy", func() {
gucumber.World["client"] = codedeploy.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@codedeploy @client
Feature: Amazon CodeDeploy
Scenario: Making a request
When I call the "ListApplications" API
Then the value at "applications" should be a list
Scenario: Handling errors
When I attempt to call the "GetDeployment" API with:
| deploymentId | d-USUAELQEX |
Then I expect the response error code to be "DeploymentDoesNotExistException"
And I expect the response error message to include:
"""
The deployment d-USUAELQEX could not be found
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package codepipeline provides gucumber integration tests support.
package codepipeline
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/codepipeline"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@codepipeline", func() {
gucumber.World["client"] = codepipeline.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@codepipeline @client
Feature: Amazon CodePipeline
Scenario: Making a request
When I call the "ListPipelines" API
Then the value at "pipelines" should be a list
Scenario: Handling errors
When I attempt to call the "GetPipeline" API with:
| name | fake-pipeline |
Then I expect the response error code to be "PipelineNotFoundException"
And I expect the response error message to include:
"""
does not have a pipeline with name 'fake-pipeline'
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cognitoidentity provides gucumber integration tests support.
package cognitoidentity
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cognitoidentity"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cognitoidentity", func() {
gucumber.World["client"] = cognitoidentity.New(smoke.Session)
})
}

View File

@@ -0,0 +1,19 @@
# language: en
@cognitoidentity @client
Feature: Amazon Cognito Idenity
Scenario: Making a request
When I call the "ListIdentityPools" API with JSON:
"""
{"MaxResults": 10}
"""
Then the value at "IdentityPools" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeIdentityPool" API with:
| IdentityPoolId | us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
IdentityPool 'us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' not found
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package cognitosync provides gucumber integration tests support.
package cognitosync
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/cognitosync"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@cognitosync", func() {
gucumber.World["client"] = cognitosync.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@cognitosync @client
Feature: Amazon Cognito Sync
Scenario: Making a request
When I call the "ListIdentityPoolUsage" API
Then the value at "IdentityPoolUsages" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeIdentityPoolUsage" API with:
| IdentityPoolId | us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
IdentityPool 'us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' not found
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package configservice provides gucumber integration tests support.
package configservice
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/configservice"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@configservice", func() {
gucumber.World["client"] = configservice.New(smoke.Session)
})
}

View File

@@ -0,0 +1,17 @@
# language: en
@configservice @config @client
Feature: AWS Config
Scenario: Making a request
When I call the "DescribeConfigurationRecorders" API
Then the value at "ConfigurationRecorders" should be a list
Scenario: Handling errors
When I attempt to call the "GetResourceConfigHistory" API with:
| resourceType | fake-type |
| resourceId | fake-id |
Then I expect the response error code to be "ValidationException"
And I expect the response error message to include:
"""
failed to satisfy constraint
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package datapipeline provides gucumber integration tests support.
package datapipeline
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/datapipeline"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@datapipeline", func() {
gucumber.World["client"] = datapipeline.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@datapipeline @client
Feature: AWS Data Pipeline
Scenario: Making a request
When I call the "ListPipelines" API
Then the response should contain a "pipelineIdList"
Scenario: Handling errors
When I attempt to call the "GetPipelineDefinition" API with:
| pipelineId | fake-id |
Then I expect the response error code to be "PipelineNotFoundException"
And I expect the response error message to include:
"""
does not exist
"""

View File

@@ -0,0 +1,19 @@
// +build integration
//Package devicefarm provides gucumber integration tests support.
package devicefarm
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/devicefarm"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@devicefarm", func() {
// FIXME remove custom region
gucumber.World["client"] = devicefarm.New(smoke.Session,
aws.NewConfig().WithRegion("us-west-2"))
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@devicefarm @client
Feature: AWS Device Farm
Scenario: Making a request
When I call the "ListDevices" API
Then the value at "devices" should be a list
Scenario: Handling errors
When I attempt to call the "GetDevice" API with:
| arn | arn:aws:devicefarm:us-west-2::device:000000000000000000000000fake-arn |
Then I expect the response error code to be "NotFoundException"
And I expect the response error message to include:
"""
No device was found for arn
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package directconnect provides gucumber integration tests support.
package directconnect
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/directconnect"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@directconnect", func() {
gucumber.World["client"] = directconnect.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@directconnect @client
Feature: AWS Direct Connect
Scenario: Making a request
When I call the "DescribeConnections" API
Then the value at "connections" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeConnections" API with:
| connectionId | fake-connection |
Then I expect the response error code to be "DirectConnectClientException"
And I expect the response error message to include:
"""
Connection ID fake-connection has an invalid format
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package directoryservice provides gucumber integration tests support.
package directoryservice
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/directoryservice"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@directoryservice", func() {
gucumber.World["client"] = directoryservice.New(smoke.Session)
})
}

View File

@@ -0,0 +1,17 @@
# language: en
@directoryservice @ds @client
Feature: AWS Directory Service
I want to use AWS Directory Service
Scenario: Making a request
When I call the "DescribeDirectories" API
Then the value at "DirectoryDescriptions" should be a list
Scenario: Handling errors
When I attempt to call the "CreateDirectory" API with:
| Name | |
| Password | |
| Size | |
Then I expect the response error code to be "ValidationException"

View File

@@ -0,0 +1,16 @@
// +build integration
//Package dynamodb provides gucumber integration tests support.
package dynamodb
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@dynamodb", func() {
gucumber.World["client"] = dynamodb.New(smoke.Session)
})
}

View File

@@ -0,0 +1,19 @@
# language: en
@dynamodb @client
Feature: Amazon DynamoDB
Scenario: Making a request
When I call the "ListTables" API with JSON:
"""
{"Limit": 1}
"""
Then the value at "TableNames" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeTable" API with:
| TableName | fake-table |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Requested resource not found: Table: fake-table not found
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package dynamodbstreams provides gucumber integration tests support.
package dynamodbstreams
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/dynamodbstreams"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@dynamodbstreams", func() {
gucumber.World["client"] = dynamodbstreams.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@dynamodbstreams @client
Feature: Amazon DynamoDB Streams
Scenario: Making a request
When I call the "ListStreams" API
Then the value at "Streams" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeStream" API with:
| StreamArn | fake-stream |
Then I expect the response error code to be "InvalidParameter"
And I expect the response error message to include:
"""
StreamArn
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package ec2 provides gucumber integration tests support.
package ec2
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@ec2", func() {
gucumber.World["client"] = ec2.New(smoke.Session)
})
}

View File

@@ -0,0 +1,18 @@
# language: en
@ec2 @client
Feature: Amazon Elastic Compute Cloud
Scenario: Making a request
When I call the "DescribeRegions" API
Then the value at "Regions" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeInstances" API with JSON:
"""
{"InstanceIds": ["i-12345678"]}
"""
Then I expect the response error code to be "InvalidInstanceID.NotFound"
And I expect the response error message to include:
"""
The instance ID 'i-12345678' does not exist
"""

View File

@@ -0,0 +1,19 @@
// +build integration
//Package ecs provides gucumber integration tests support.
package ecs
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@ecs", func() {
// FIXME remove custom region
gucumber.World["client"] = ecs.New(smoke.Session,
aws.NewConfig().WithRegion("us-west-2"))
})
}

View File

@@ -0,0 +1,14 @@
# language: en
@ecs @client
Feature: Amazon ECS
I want to use Amazon ECS
Scenario: Making a request
When I call the "ListClusters" API
Then the value at "clusterArns" should be a list
Scenario: Handling errors
When I attempt to call the "StopTask" API with:
| task | xxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxx |
Then the error code should be "ClusterNotFoundException"

View File

@@ -0,0 +1,19 @@
// +build integration
//Package efs provides gucumber integration tests support.
package efs
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/efs"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@efs", func() {
// FIXME remove custom region
gucumber.World["client"] = efs.New(smoke.Session,
aws.NewConfig().WithRegion("us-west-2"))
})
}

View File

@@ -0,0 +1,14 @@
# language: en
@efs @elasticfilesystem @client
Feature: Amazon Elastic File System
I want to use Amazon Elastic File System
Scenario: Making a request
When I call the "DescribeFileSystems" API
Then the value at "FileSystems" should be a list
Scenario: Handling errors
When I attempt to call the "DeleteFileSystem" API with:
| FileSystemId | fake-id |
Then the error code should be "BadRequest"

View File

@@ -0,0 +1,16 @@
// +build integration
//Package elasticache provides gucumber integration tests support.
package elasticache
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@elasticache", func() {
gucumber.World["client"] = elasticache.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@elasticache @client
Feature: ElastiCache
Scenario: Making a request
When I call the "DescribeEvents" API
Then the value at "Events" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeCacheClusters" API with:
| CacheClusterId | fake_cluster |
Then I expect the response error code to be "InvalidParameterValue"
And I expect the response error message to include:
"""
The parameter CacheClusterIdentifier is not a valid identifier.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package elasticbeanstalk provides gucumber integration tests support.
package elasticbeanstalk
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@elasticbeanstalk", func() {
gucumber.World["client"] = elasticbeanstalk.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@elasticbeanstalk @client
Feature: AWS Elastic Beanstalk
Scenario: Making a request
When I call the "ListAvailableSolutionStacks" API
Then the value at "SolutionStacks" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeEnvironmentResources" API with:
| EnvironmentId | fake_environment |
Then I expect the response error code to be "InvalidParameterValue"
And I expect the response error message to include:
"""
No Environment found for EnvironmentId = 'fake_environment'.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package elasticloadbalancing provides gucumber integration tests support.
package elasticloadbalancing
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@elasticloadbalancing", func() {
gucumber.World["client"] = elb.New(smoke.Session)
})
}

View File

@@ -0,0 +1,18 @@
# language: en
@elasticloadbalancing @client
Feature: Elastic Load Balancing
Scenario: Making a request
When I call the "DescribeLoadBalancers" API
Then the value at "LoadBalancerDescriptions" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeLoadBalancers" API with JSON:
"""
{"LoadBalancerNames": ["fake_load_balancer"]}
"""
Then I expect the response error code to be "ValidationError"
And I expect the response error message to include:
"""
LoadBalancer name cannot contain characters that are not letters, or digits or the dash.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package elastictranscoder provides gucumber integration tests support.
package elastictranscoder
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/elastictranscoder"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@elastictranscoder", func() {
gucumber.World["client"] = elastictranscoder.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@elastictranscoder @client
Feature: Amazon Elastic Transcoder
Scenario: Making a request
When I call the "ListPresets" API
Then the value at "Presets" should be a list
Scenario: Handling errors
When I attempt to call the "ReadJob" API with:
| Id | fake_job |
Then I expect the response error code to be "ValidationException"
And I expect the response error message to include:
"""
Value 'fake_job' at 'id' failed to satisfy constraint
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package emr provides gucumber integration tests support.
package emr
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/emr"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@emr", func() {
gucumber.World["client"] = emr.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@emr @client @elasticmapreduce
Feature: Amazon EMR
Scenario: Making a request
When I call the "ListClusters" API
Then the value at "Clusters" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeCluster" API with:
| ClusterId | fake_cluster |
Then I expect the response error code to be "InvalidRequestException"
And I expect the response error message to include:
"""
Cluster id 'fake_cluster' is not valid.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package es provides gucumber integration tests support.
package es
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/elasticsearchservice"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@es", func() {
gucumber.World["client"] = elasticsearchservice.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@es @elasticsearchservice
Feature: Amazon ElasticsearchService
Scenario: Making a request
When I call the "ListDomainNames" API
Then the value at "DomainNames" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeElasticsearchDomain" API with:
| DomainName | not-a-domain |
Then the error code should be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Domain not found: not-a-domain
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package glacier provides gucumber integration tests support.
package glacier
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/glacier"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@glacier", func() {
gucumber.World["client"] = glacier.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@glacier @client
Feature: Amazon Glacier
Scenario: Making a request
When I call the "ListVaults" API
Then the response should contain a "VaultList"
Scenario: Handling errors
When I attempt to call the "ListVaults" API with:
| accountId | abcmnoxyz |
Then I expect the response error code to be "UnrecognizedClientException"
And I expect the response error message to include:
"""
No account found for the given parameters
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package iam provides gucumber integration tests support.
package iam
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@iam", func() {
gucumber.World["client"] = iam.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@iam @client
Feature: AWS Identity and Access Management
Scenario: Making a request
When I call the "ListUsers" API
Then the value at "Users" should be a list
Scenario: Handling errors
When I attempt to call the "GetUser" API with:
| UserName | fake_user |
Then I expect the response error code to be "NoSuchEntity"
And I expect the response error message to include:
"""
The user with name fake_user cannot be found.
"""

View File

@@ -0,0 +1,29 @@
// +build integration
//Package iotdataplane provides gucumber integration tests support.
package iotdataplane
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/iot"
"github.com/aws/aws-sdk-go/service/iotdataplane"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@iotdataplane", func() {
svc := iot.New(smoke.Session)
result, err := svc.DescribeEndpoint(&iot.DescribeEndpointInput{})
if err != nil {
gucumber.World["error"] = err
return
}
fmt.Println("IOT Data endpoint:", *result.EndpointAddress)
gucumber.World["client"] = iotdataplane.New(smoke.Session, aws.NewConfig().
WithEndpoint(*result.EndpointAddress))
})
}

View File

@@ -0,0 +1,9 @@
# language: en
@iotdataplane @client
Feature: AWS IoT Data Plane
Scenario: Handling errors
When I attempt to call the "GetThingShadow" API with:
| thingName | fake-thing |
Then I expect the response error code to be "ResourceNotFoundException"

View File

@@ -0,0 +1,16 @@
// +build integration
//Package kinesis provides gucumber integration tests support.
package kinesis
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@kinesis", func() {
gucumber.World["client"] = kinesis.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@kinesis @client
Feature: AWS Kinesis
Scenario: Making a request
When I call the "ListStreams" API
Then the value at "StreamNames" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeStream" API with:
| StreamName | bogus-stream-name |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Stream bogus-stream-name under account
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package kms provides gucumber integration tests support.
package kms
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@kms", func() {
gucumber.World["client"] = kms.New(smoke.Session)
})
}

View File

@@ -0,0 +1,13 @@
# language: en
@kms @client
Feature: Amazon Key Management Service
Scenario: Making a request
When I call the "ListAliases" API
Then the value at "Aliases" should be a list
Scenario: Handling errors
When I attempt to call the "GetKeyPolicy" API with:
| KeyId | fake-key |
| PolicyName | fakepolicy |
Then I expect the response error code to be "NotFoundException"

View File

@@ -0,0 +1,16 @@
// +build integration
//Package lambda provides gucumber integration tests support.
package lambda
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@lambda", func() {
gucumber.World["client"] = lambda.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@lambda @client
Feature: Amazon Lambda
Scenario: Making a request
When I call the "ListFunctions" API
Then the value at "Functions" should be a list
Scenario: Handling errors
When I attempt to call the "Invoke" API with:
| FunctionName | bogus-function |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Function not found
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package machinelearning provides gucumber integration tests support.
package machinelearning
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/machinelearning"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@machinelearning", func() {
gucumber.World["client"] = machinelearning.New(smoke.Session)
})
}

View File

@@ -0,0 +1,18 @@
# language: en
@machinelearning @client
Feature: Amazon Machine Learning
I want to use Amazon Machine Learning
Scenario: Making a request
When I call the "DescribeMLModels" API
Then the value at "Results" should be a list
Scenario: Error handling
When I attempt to call the "GetBatchPrediction" API with:
| BatchPredictionId | fake-id |
Then the error code should be "ResourceNotFoundException"
And the error message should contain:
"""
No BatchPrediction with id fake-id exists
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package opsworks provides gucumber integration tests support.
package opsworks
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/opsworks"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@opsworks", func() {
gucumber.World["client"] = opsworks.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@opsworks @client
Feature: AWS OpsWorks
Scenario: Making a request
When I call the "DescribeStacks" API
Then the value at "Stacks" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeLayers" API with:
| StackId | fake_stack |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Unable to find stack with ID fake_stack
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package rds provides gucumber integration tests support.
package rds
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/rds"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@rds", func() {
gucumber.World["client"] = rds.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@rds @client
Feature: Amazon RDS
Scenario: Making a request
When I call the "DescribeDBEngineVersions" API
Then the value at "DBEngineVersions" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeDBInstances" API with:
| DBInstanceIdentifier | fake-id |
Then I expect the response error code to be "DBInstanceNotFound"
And I expect the response error message to include:
"""
DBInstance fake-id not found.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package redshift provides gucumber integration tests support.
package redshift
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/redshift"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@redshift", func() {
gucumber.World["client"] = redshift.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@redshift @client
Feature: Amazon Redshift
Scenario: Making a request
When I call the "DescribeClusterVersions" API
Then the value at "ClusterVersions" should be a list
Scenario: Handling errors
When I attempt to call the "DescribeClusters" API with:
| ClusterIdentifier | fake-cluster |
Then I expect the response error code to be "ClusterNotFound"
And I expect the response error message to include:
"""
Cluster fake-cluster not found.
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package route53 provides gucumber integration tests support.
package route53
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@route53", func() {
gucumber.World["client"] = route53.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@route53 @client
Feature: Amazon Route 53
Scenario: Making a request
When I call the "ListHostedZones" API
Then the value at "HostedZones" should be a list
Scenario: Handling errors
When I attempt to call the "GetHostedZone" API with:
| Id | fake-zone |
Then I expect the response error code to be "NoSuchHostedZone"
And I expect the response error message to include:
"""
No hosted zone found with ID: fake-zone
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package route53domains provides gucumber integration tests support.
package route53domains
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/route53domains"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@route53domains", func() {
gucumber.World["client"] = route53domains.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@route53domains @client
Feature: Amazon Route53 Domains
Scenario: Making a request
When I call the "ListDomains" API
Then the value at "Domains" should be a list
Scenario: Handling errors
When I attempt to call the "GetDomainDetail" API with:
| DomainName | fake-domain-name |
Then I expect the response error code to be "InvalidInput"
And I expect the response error message to include:
"""
domain name must contain more than 1 label
"""

View File

@@ -0,0 +1,16 @@
// +build integration
//Package ses provides gucumber integration tests support.
package ses
import (
"github.com/aws/aws-sdk-go/awstesting/integration/smoke"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/gucumber/gucumber"
)
func init() {
gucumber.Before("@ses", func() {
gucumber.World["client"] = ses.New(smoke.Session)
})
}

View File

@@ -0,0 +1,16 @@
# language: en
@ses @email @client
Feature: Amazon Simple Email Service
Scenario: Making a request
When I call the "ListIdentities" API
Then the value at "Identities" should be a list
Scenario: Handling errors
When I attempt to call the "VerifyEmailIdentity" API with:
| EmailAddress | fake_email |
Then I expect the response error code to be "InvalidParameterValue"
And I expect the response error message to include:
"""
Invalid email address<fake_email>.
"""

View File

@@ -0,0 +1,230 @@
// +build integration
// Package smoke contains shared step definitions that are used across integration tests
package smoke
import (
"encoding/json"
"fmt"
"os"
"reflect"
"regexp"
"strconv"
"strings"
"github.com/gucumber/gucumber"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/session"
)
// Session is a shared session for all integration smoke tests to use.
var Session = session.Must(session.NewSession())
func init() {
logLevel := Session.Config.LogLevel
if os.Getenv("DEBUG") != "" {
logLevel = aws.LogLevel(aws.LogDebug)
}
if os.Getenv("DEBUG_SIGNING") != "" {
logLevel = aws.LogLevel(aws.LogDebugWithSigning)
}
if os.Getenv("DEBUG_BODY") != "" {
logLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
}
Session.Config.LogLevel = logLevel
gucumber.When(`^I call the "(.+?)" API$`, func(op string) {
call(op, nil, false)
})
gucumber.When(`^I call the "(.+?)" API with:$`, func(op string, args [][]string) {
call(op, args, false)
})
gucumber.Then(`^the value at "(.+?)" should be a list$`, func(member string) {
vals, _ := awsutil.ValuesAtPath(gucumber.World["response"], member)
assert.NotNil(gucumber.T, vals)
})
gucumber.Then(`^the response should contain a "(.+?)"$`, func(member string) {
vals, _ := awsutil.ValuesAtPath(gucumber.World["response"], member)
assert.NotEmpty(gucumber.T, vals)
})
gucumber.When(`^I attempt to call the "(.+?)" API with:$`, func(op string, args [][]string) {
call(op, args, true)
})
gucumber.Then(`^I expect the response error code to be "(.+?)"$`, func(code string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if ok {
assert.Equal(gucumber.T, code, err.Code(), "Error: %v", err)
}
})
gucumber.And(`^I expect the response error message to include:$`, func(data string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if ok {
assert.Contains(gucumber.T, err.Error(), data)
}
})
gucumber.And(`^I expect the response error message to include one of:$`, func(table [][]string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if ok {
found := false
for _, row := range table {
if strings.Contains(err.Error(), row[0]) {
found = true
break
}
}
assert.True(gucumber.T, found, fmt.Sprintf("no error messages matched: \"%s\"", err.Error()))
}
})
gucumber.And(`^I expect the response error message not be empty$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.NotEmpty(gucumber.T, err.Message())
})
gucumber.When(`^I call the "(.+?)" API with JSON:$`, func(s1 string, data string) {
callWithJSON(s1, data, false)
})
gucumber.When(`^I attempt to call the "(.+?)" API with JSON:$`, func(s1 string, data string) {
callWithJSON(s1, data, true)
})
gucumber.Then(`^the error code should be "(.+?)"$`, func(s1 string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Equal(gucumber.T, s1, err.Code())
})
gucumber.And(`^the error message should contain:$`, func(data string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Contains(gucumber.T, err.Error(), data)
})
gucumber.Then(`^the request should fail$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Error(gucumber.T, err)
})
gucumber.Then(`^the request should be successful$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.False(gucumber.T, ok, "error returned")
assert.NoError(gucumber.T, err)
})
}
// findMethod finds the op operation on the v structure using a case-insensitive
// lookup. Returns nil if no method is found.
func findMethod(v reflect.Value, op string) *reflect.Value {
t := v.Type()
op = strings.ToLower(op)
for i := 0; i < t.NumMethod(); i++ {
name := t.Method(i).Name
if strings.ToLower(name) == op {
m := v.MethodByName(name)
return &m
}
}
return nil
}
// call calls an operation on gucumber.World["client"] by the name op using the args
// table of arguments to set.
func call(op string, args [][]string, allowError bool) {
v := reflect.ValueOf(gucumber.World["client"])
if m := findMethod(v, op); m != nil {
t := m.Type()
in := reflect.New(t.In(0).Elem())
fillArgs(in, args)
resps := m.Call([]reflect.Value{in})
gucumber.World["response"] = resps[0].Interface()
gucumber.World["error"] = resps[1].Interface()
if !allowError {
err, _ := gucumber.World["error"].(error)
assert.NoError(gucumber.T, err)
}
} else {
assert.Fail(gucumber.T, "failed to find operation "+op)
}
}
// reIsNum is a regular expression matching a numeric input (integer)
var reIsNum = regexp.MustCompile(`^\d+$`)
// reIsArray is a regular expression matching a list
var reIsArray = regexp.MustCompile(`^\['.*?'\]$`)
var reArrayElem = regexp.MustCompile(`'(.+?)'`)
// fillArgs fills arguments on the input structure using the args table of
// arguments.
func fillArgs(in reflect.Value, args [][]string) {
if args == nil {
return
}
for _, row := range args {
path := row[0]
var val interface{} = row[1]
if reIsArray.MatchString(row[1]) {
quotedStrs := reArrayElem.FindAllString(row[1], -1)
strs := make([]*string, len(quotedStrs))
for i, e := range quotedStrs {
str := e[1 : len(e)-1]
strs[i] = &str
}
val = strs
} else if reIsNum.MatchString(row[1]) { // handle integer values
num, err := strconv.ParseInt(row[1], 10, 64)
if err == nil {
val = num
}
}
awsutil.SetValueAtPath(in.Interface(), path, val)
}
}
func callWithJSON(op, j string, allowError bool) {
v := reflect.ValueOf(gucumber.World["client"])
if m := findMethod(v, op); m != nil {
t := m.Type()
in := reflect.New(t.In(0).Elem())
fillJSON(in, j)
resps := m.Call([]reflect.Value{in})
gucumber.World["response"] = resps[0].Interface()
gucumber.World["error"] = resps[1].Interface()
if !allowError {
err, _ := gucumber.World["error"].(error)
assert.NoError(gucumber.T, err)
}
} else {
assert.Fail(gucumber.T, "failed to find operation "+op)
}
}
func fillJSON(in reflect.Value, j string) {
d := json.NewDecoder(strings.NewReader(j))
if err := d.Decode(in.Interface()); err != nil {
panic(err)
}
}

Some files were not shown because too many files have changed in this diff Show More