migrate from govendor to dep
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
Please fill out the sections below to help us address your issue.
|
||||
|
||||
### Version of AWS SDK for Go?
|
||||
|
||||
|
||||
### Version of Go (`go version`)?
|
||||
|
||||
|
||||
### What issue did you see?
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
If you have have an runnable example, please include it.
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
For changes to files under the `/model/` folder, and manual edits to autogenerated code (e.g. `/service/s3/api.go`) please create an Issue instead of a PR for those type of changes.
|
||||
|
||||
If there is an existing bug or feature this PR is answers please reference it here.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
dist
|
||||
/doc
|
||||
/doc-staging
|
||||
.yardoc
|
||||
Gemfile.lock
|
||||
awstesting/integration/smoke/**/importmarker__.go
|
||||
awstesting/integration/smoke/_test/
|
||||
/vendor/bin/
|
||||
/vendor/pkg/
|
||||
/vendor/src/
|
||||
/private/model/cli/gen-api/gen-api
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"PkgHandler": {
|
||||
"Pattern": "/sdk-for-go/api/",
|
||||
"StripPrefix": "/sdk-for-go/api",
|
||||
"Include": ["/src/github.com/aws/aws-sdk-go/aws", "/src/github.com/aws/aws-sdk-go/service"],
|
||||
"Exclude": ["/src/cmd", "/src/github.com/aws/aws-sdk-go/awstesting", "/src/github.com/aws/aws-sdk-go/awsmigrate"],
|
||||
"IgnoredSuffixes": ["iface"]
|
||||
},
|
||||
"Github": {
|
||||
"Tag": "master",
|
||||
"Repo": "/aws/aws-sdk-go",
|
||||
"UseGithub": true
|
||||
}
|
||||
}
|
||||
+1107
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -67,7 +67,7 @@ Please be aware of the following notes prior to opening a pull request:
|
||||
5. The JSON files under the SDK's `models` folder are sourced from outside the SDK.
|
||||
Such as `models/apis/ec2/2016-11-15/api.json`. We will not accept pull requests
|
||||
directly on these models. If you discover an issue with the models please
|
||||
create a Github [issue](issues) describing the issue.
|
||||
create a [GitHub issue][issues] describing the issue.
|
||||
|
||||
### Testing
|
||||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/go-ini/ini"
|
||||
packages = ["."]
|
||||
revision = "300e940a926eb277d3901b20bdfcc54928ad3642"
|
||||
version = "v1.25.4"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/jmespath/go-jmespath"
|
||||
packages = ["."]
|
||||
revision = "0b12d6b5"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "51a86a867df617990082dec6b868e4efe2fdb2ed0e02a3daa93cd30f962b5085"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
|
||||
ignored = [
|
||||
# Testing/Example/Codegen dependencies
|
||||
"github.com/stretchr/testify",
|
||||
"github.com/stretchr/testify/assert",
|
||||
"github.com/stretchr/testify/require",
|
||||
"github.com/go-sql-driver/mysql",
|
||||
"github.com/gucumber/gucumber",
|
||||
"github.com/pkg/errors",
|
||||
"golang.org/x/net",
|
||||
"golang.org/x/net/html",
|
||||
"golang.org/x/net/http2",
|
||||
"golang.org/x/text",
|
||||
"golang.org/x/text/html",
|
||||
"golang.org/x/tools",
|
||||
"golang.org/x/tools/go/loader",
|
||||
]
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/go-ini/ini"
|
||||
version = "1.25.4"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/jmespath/go-jmespath"
|
||||
revision = "0b12d6b5"
|
||||
#version = "0.2.2"
|
||||
+8
-1
@@ -74,7 +74,7 @@ smoke-tests: get-deps-tests
|
||||
performance: get-deps-tests
|
||||
AWS_TESTING_LOG_RESULTS=${log-detailed} AWS_TESTING_REGION=$(region) AWS_TESTING_DB_TABLE=$(table) gucumber -go-tags "integration" ./awstesting/performance
|
||||
|
||||
sandbox-tests: sandbox-test-go15 sandbox-test-go15-novendorexp sandbox-test-go16 sandbox-test-go17 sandbox-test-go18 sandbox-test-gotip
|
||||
sandbox-tests: sandbox-test-go15 sandbox-test-go15-novendorexp sandbox-test-go16 sandbox-test-go17 sandbox-test-go18 sandbox-test-go19 sandbox-test-gotip
|
||||
|
||||
sandbox-build-go15:
|
||||
docker build -f ./awstesting/sandbox/Dockerfile.test.go1.5 -t "aws-sdk-go-1.5" .
|
||||
@@ -111,6 +111,13 @@ sandbox-go18: sandbox-build-go18
|
||||
sandbox-test-go18: sandbox-build-go18
|
||||
docker run -t aws-sdk-go-1.8
|
||||
|
||||
sandbox-build-go19:
|
||||
docker build -f ./awstesting/sandbox/Dockerfile.test.go1.8 -t "aws-sdk-go-1.9" .
|
||||
sandbox-go19: sandbox-build-go19
|
||||
docker run -i -t aws-sdk-go-1.9 bash
|
||||
sandbox-test-go19: sandbox-build-go19
|
||||
docker run -t aws-sdk-go-1.9
|
||||
|
||||
sandbox-build-gotip:
|
||||
@echo "Run make update-aws-golang-tip, if this test fails because missing aws-golang:tip container"
|
||||
docker build -f ./awstesting/sandbox/Dockerfile.test.gotip -t "aws-sdk-go-tip" .
|
||||
|
||||
+5
-3
@@ -6,6 +6,8 @@ aws-sdk-go is the official AWS SDK for the Go programming language.
|
||||
|
||||
Checkout our [release notes](https://github.com/aws/aws-sdk-go/releases) for information about the latest bug fixes, updates, and features added to the SDK.
|
||||
|
||||
We [announced](https://aws.amazon.com/blogs/developer/aws-sdk-for-go-2-0-developer-preview/) the Developer Preview for the [v2 AWS SDK for Go](). The v2 SDK is available at https://github.com/aws/aws-sdk-go-v2, and `go get github.com/aws/aws-sdk-go-v2` via `go get`. Check out the v2 SDK's [changes and updates](https://github.com/aws/aws-sdk-go-v2/blob/master/CHANGELOG.md), and let us know what you think. We want your feedback.
|
||||
|
||||
## Installing
|
||||
|
||||
If you are using Go 1.5 with the `GO15VENDOREXPERIMENT=1` vendoring flag, or 1.6 and higher you can use the following command to retrieve the SDK. The SDK's non-testing dependencies will be included and are vendored in the `vendor` folder.
|
||||
@@ -167,7 +169,7 @@ and configures the S3 service client to use that role for API requests.
|
||||
|
||||
// Create service client value configured for credentials
|
||||
// from assumed role.
|
||||
svc := s3.New(sess, &aws.Config{Credentials: creds})/
|
||||
svc := s3.New(sess, &aws.Config{Credentials: creds})
|
||||
```
|
||||
|
||||
See the [credentials][credentials_pkg] package documentation for more information on credential
|
||||
@@ -185,7 +187,7 @@ Option's SharedConfigState parameter.
|
||||
}))
|
||||
```
|
||||
|
||||
[credentials_pkg]: ttps://docs.aws.amazon.com/sdk-for-go/api/aws/credentials
|
||||
[credentials_pkg]: https://docs.aws.amazon.com/sdk-for-go/api/aws/credentials
|
||||
|
||||
### Configuring AWS Region
|
||||
|
||||
@@ -305,7 +307,7 @@ documentation for the errors that could be returned.
|
||||
// will leak connections.
|
||||
defer result.Body.Close()
|
||||
|
||||
fmt.Println("Object Size:", aws.StringValue(result.ContentLength))
|
||||
fmt.Println("Object Size:", aws.Int64Value(result.ContentLength))
|
||||
```
|
||||
|
||||
### API Request Pagination and Resource Waiters
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
// Package arn provides a parser for interacting with Amazon Resource Names.
|
||||
package arn
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
arnDelimiter = ":"
|
||||
arnSections = 6
|
||||
arnPrefix = "arn:"
|
||||
|
||||
// zero-indexed
|
||||
sectionPartition = 1
|
||||
sectionService = 2
|
||||
sectionRegion = 3
|
||||
sectionAccountID = 4
|
||||
sectionResource = 5
|
||||
|
||||
// errors
|
||||
invalidPrefix = "arn: invalid prefix"
|
||||
invalidSections = "arn: not enough sections"
|
||||
)
|
||||
|
||||
// ARN captures the individual fields of an Amazon Resource Name.
|
||||
// See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html for more information.
|
||||
type ARN struct {
|
||||
// The partition that the resource is in. For standard AWS regions, the partition is "aws". If you have resources in
|
||||
// other partitions, the partition is "aws-partitionname". For example, the partition for resources in the China
|
||||
// (Beijing) region is "aws-cn".
|
||||
Partition string
|
||||
|
||||
// The service namespace that identifies the AWS product (for example, Amazon S3, IAM, or Amazon RDS). For a list of
|
||||
// namespaces, see
|
||||
// http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces.
|
||||
Service string
|
||||
|
||||
// The region the resource resides in. Note that the ARNs for some resources do not require a region, so this
|
||||
// component might be omitted.
|
||||
Region string
|
||||
|
||||
// The ID of the AWS account that owns the resource, without the hyphens. For example, 123456789012. Note that the
|
||||
// ARNs for some resources don't require an account number, so this component might be omitted.
|
||||
AccountID string
|
||||
|
||||
// The content of this part of the ARN varies by service. It often includes an indicator of the type of resource —
|
||||
// for example, an IAM user or Amazon RDS database - followed by a slash (/) or a colon (:), followed by the
|
||||
// resource name itself. Some services allows paths for resource names, as described in
|
||||
// http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arns-paths.
|
||||
Resource string
|
||||
}
|
||||
|
||||
// Parse parses an ARN into its constituent parts.
|
||||
//
|
||||
// Some example ARNs:
|
||||
// arn:aws:elasticbeanstalk:us-east-1:123456789012:environment/My App/MyEnvironment
|
||||
// arn:aws:iam::123456789012:user/David
|
||||
// arn:aws:rds:eu-west-1:123456789012:db:mysql-db
|
||||
// arn:aws:s3:::my_corporate_bucket/exampleobject.png
|
||||
func Parse(arn string) (ARN, error) {
|
||||
if !strings.HasPrefix(arn, arnPrefix) {
|
||||
return ARN{}, errors.New(invalidPrefix)
|
||||
}
|
||||
sections := strings.SplitN(arn, arnDelimiter, arnSections)
|
||||
if len(sections) != arnSections {
|
||||
return ARN{}, errors.New(invalidSections)
|
||||
}
|
||||
return ARN{
|
||||
Partition: sections[sectionPartition],
|
||||
Service: sections[sectionService],
|
||||
Region: sections[sectionRegion],
|
||||
AccountID: sections[sectionAccountID],
|
||||
Resource: sections[sectionResource],
|
||||
}, nil
|
||||
}
|
||||
|
||||
// String returns the canonical representation of the ARN
|
||||
func (arn ARN) String() string {
|
||||
return arnPrefix +
|
||||
arn.Partition + arnDelimiter +
|
||||
arn.Service + arnDelimiter +
|
||||
arn.Region + arnDelimiter +
|
||||
arn.AccountID + arnDelimiter +
|
||||
arn.Resource
|
||||
}
|
||||
+50
-8
@@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -38,14 +39,18 @@ func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration {
|
||||
minTime := 30
|
||||
throttle := d.shouldThrottle(r)
|
||||
if throttle {
|
||||
if delay, ok := getRetryDelay(r); ok {
|
||||
return delay
|
||||
}
|
||||
|
||||
minTime = 500
|
||||
}
|
||||
|
||||
retryCount := r.RetryCount
|
||||
if retryCount > 13 {
|
||||
retryCount = 13
|
||||
} else if throttle && retryCount > 8 {
|
||||
if throttle && retryCount > 8 {
|
||||
retryCount = 8
|
||||
} else if retryCount > 13 {
|
||||
retryCount = 13
|
||||
}
|
||||
|
||||
delay := (1 << uint(retryCount)) * (seededRand.Intn(minTime) + minTime)
|
||||
@@ -68,12 +73,49 @@ func (d DefaultRetryer) ShouldRetry(r *request.Request) bool {
|
||||
|
||||
// ShouldThrottle returns true if the request should be throttled.
|
||||
func (d DefaultRetryer) shouldThrottle(r *request.Request) bool {
|
||||
if r.HTTPResponse.StatusCode == 502 ||
|
||||
r.HTTPResponse.StatusCode == 503 ||
|
||||
r.HTTPResponse.StatusCode == 504 {
|
||||
return true
|
||||
switch r.HTTPResponse.StatusCode {
|
||||
case 429:
|
||||
case 502:
|
||||
case 503:
|
||||
case 504:
|
||||
default:
|
||||
return r.IsErrorThrottle()
|
||||
}
|
||||
return r.IsErrorThrottle()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// This will look in the Retry-After header, RFC 7231, for how long
|
||||
// it will wait before attempting another request
|
||||
func getRetryDelay(r *request.Request) (time.Duration, bool) {
|
||||
if !canUseRetryAfterHeader(r) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
delayStr := r.HTTPResponse.Header.Get("Retry-After")
|
||||
if len(delayStr) == 0 {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
delay, err := strconv.Atoi(delayStr)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return time.Duration(delay) * time.Second, true
|
||||
}
|
||||
|
||||
// Will look at the status code to see if the retry header pertains to
|
||||
// the status code.
|
||||
func canUseRetryAfterHeader(r *request.Request) bool {
|
||||
switch r.HTTPResponse.StatusCode {
|
||||
case 429:
|
||||
case 503:
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// lockedSource is a thread-safe implementation of rand.Source
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ type Config struct {
|
||||
//
|
||||
EC2MetadataDisableTimeoutOverride *bool
|
||||
|
||||
// Instructs the endpiont to be generated for a service client to
|
||||
// Instructs the endpoint to be generated for a service client to
|
||||
// be the dual stack endpoint. The dual stack endpoint will support
|
||||
// both IPv4 and IPv6 addressing.
|
||||
//
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ package aws
|
||||
|
||||
import "time"
|
||||
|
||||
// An emptyCtx is a copy of the the Go 1.7 context.emptyCtx type. This
|
||||
// is copied to provide a 1.6 and 1.5 safe version of context that is compatible
|
||||
// with Go 1.7's Context.
|
||||
// An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to
|
||||
// provide a 1.6 and 1.5 safe version of context that is compatible with Go
|
||||
// 1.7's Context.
|
||||
//
|
||||
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
|
||||
// struct{}, since vars of this type must have distinct addresses.
|
||||
|
||||
+18
@@ -311,6 +311,24 @@ func TimeValue(v *time.Time) time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
// SecondsTimeValue converts an int64 pointer to a time.Time value
|
||||
// representing seconds since Epoch or time.Time{} if the pointer is nil.
|
||||
func SecondsTimeValue(v *int64) time.Time {
|
||||
if v != nil {
|
||||
return time.Unix((*v / 1000), 0)
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
// MillisecondsTimeValue converts an int64 pointer to a time.Time value
|
||||
// representing milliseconds sinch Epoch or time.Time{} if the pointer is nil.
|
||||
func MillisecondsTimeValue(v *int64) time.Time {
|
||||
if v != nil {
|
||||
return time.Unix(0, (*v * 1000000))
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
// TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC".
|
||||
// The result is undefined if the Unix time cannot be represented by an int64.
|
||||
// Which includes calling TimeUnixMilli on a zero Time is undefined.
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// +build !go1.8
|
||||
|
||||
// Package plugincreds provides usage of Go plugins for providing credentials
|
||||
// to the SDK. Only available with Go 1.8 and above.
|
||||
package plugincreds
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
// +build go1.8
|
||||
|
||||
// Package plugincreds implements a credentials provider sourced from a Go
|
||||
// plugin. This package allows you to use a Go plugin to retrieve AWS credentials
|
||||
// for the SDK to use for service API calls.
|
||||
//
|
||||
// As of Go 1.8 plugins are only supported on the Linux platform.
|
||||
//
|
||||
// Plugin Symbol Name
|
||||
//
|
||||
// The "GetAWSSDKCredentialProvider" is the symbol name that will be used to
|
||||
// lookup the credentials provider getter from the plugin. If you want to use a
|
||||
// custom symbol name you should use GetPluginProviderFnsByName to lookup the
|
||||
// symbol by a custom name.
|
||||
//
|
||||
// This symbol is a function that returns two additional functions. One to
|
||||
// retrieve the credentials, and another to determine if the credentials have
|
||||
// expired.
|
||||
//
|
||||
// Plugin Symbol Signature
|
||||
//
|
||||
// The plugin credential provider requires the symbol to match the
|
||||
// following signature.
|
||||
//
|
||||
// func() (RetrieveFn func() (key, secret, token string, err error), IsExpiredFn func() bool)
|
||||
//
|
||||
// Plugin Implementation Exmaple
|
||||
//
|
||||
// The following is an example implementation of a SDK credential provider using
|
||||
// the plugin provider in this package. See the SDK's example/aws/credential/plugincreds/plugin
|
||||
// folder for a runnable example of this.
|
||||
//
|
||||
// package main
|
||||
//
|
||||
// func main() {}
|
||||
//
|
||||
// var myCredProvider provider
|
||||
//
|
||||
// // Build: go build -o plugin.so -buildmode=plugin plugin.go
|
||||
// func init() {
|
||||
// // Initialize a mock credential provider with stubs
|
||||
// myCredProvider = provider{"a","b","c"}
|
||||
// }
|
||||
//
|
||||
// // GetAWSSDKCredentialProvider is the symbol SDK will lookup and use to
|
||||
// // get the credential provider's retrieve and isExpired functions.
|
||||
// func GetAWSSDKCredentialProvider() (func() (key, secret, token string, err error), func() bool) {
|
||||
// return myCredProvider.Retrieve, myCredProvider.IsExpired
|
||||
// }
|
||||
//
|
||||
// // mock implementation of a type that returns retrieves credentials and
|
||||
// // returns if they have expired.
|
||||
// type provider struct {
|
||||
// key, secret, token string
|
||||
// }
|
||||
//
|
||||
// func (p provider) Retrieve() (key, secret, token string, err error) {
|
||||
// return p.key, p.secret, p.token, nil
|
||||
// }
|
||||
//
|
||||
// func (p *provider) IsExpired() bool {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// Configuring SDK for Plugin Credentials
|
||||
//
|
||||
// To configure the SDK to use a plugin's credential provider you'll need to first
|
||||
// open the plugin file using the plugin standard library package. Once you have
|
||||
// a handle to the plugin you can use the NewCredentials function of this package
|
||||
// to create a new credentials.Credentials value that can be set as the
|
||||
// credentials loader of a Session or Config. See the SDK's example/aws/credential/plugincreds
|
||||
// folder for a runnable example of this.
|
||||
//
|
||||
// // Open plugin, and load it into the process.
|
||||
// p, err := plugin.Open("somefile.so")
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// // Create a new Credentials value which will source the provider's Retrieve
|
||||
// // and IsExpired functions from the plugin.
|
||||
// creds, err := plugincreds.NewCredentials(p)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// // Example to configure a Session with the newly created credentials that
|
||||
// // will be sourced using the plugin's functionality.
|
||||
// sess := session.Must(session.NewSession(&aws.Config{
|
||||
// Credentials: creds,
|
||||
// }))
|
||||
package plugincreds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"plugin"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
)
|
||||
|
||||
// ProviderSymbolName the symbol name the SDK will use to lookup the plugin
|
||||
// provider value from.
|
||||
const ProviderSymbolName = `GetAWSSDKCredentialProvider`
|
||||
|
||||
// ProviderName is the name this credentials provider will label any returned
|
||||
// credentials Value with.
|
||||
const ProviderName = `PluginCredentialsProvider`
|
||||
|
||||
const (
|
||||
// ErrCodeLookupSymbolError failed to lookup symbol
|
||||
ErrCodeLookupSymbolError = "LookupSymbolError"
|
||||
|
||||
// ErrCodeInvalidSymbolError symbol invalid
|
||||
ErrCodeInvalidSymbolError = "InvalidSymbolError"
|
||||
|
||||
// ErrCodePluginRetrieveNil Retrieve function was nil
|
||||
ErrCodePluginRetrieveNil = "PluginRetrieveNilError"
|
||||
|
||||
// ErrCodePluginIsExpiredNil IsExpired Function was nil
|
||||
ErrCodePluginIsExpiredNil = "PluginIsExpiredNilError"
|
||||
|
||||
// ErrCodePluginProviderRetrieve plugin provider's retrieve returned error
|
||||
ErrCodePluginProviderRetrieve = "PluginProviderRetrieveError"
|
||||
)
|
||||
|
||||
// Provider is the credentials provider that will use the plugin provided
|
||||
// Retrieve and IsExpired functions to retrieve credentials.
|
||||
type Provider struct {
|
||||
RetrieveFn func() (key, secret, token string, err error)
|
||||
IsExpiredFn func() bool
|
||||
}
|
||||
|
||||
// NewCredentials returns a new Credentials loader using the plugin provider.
|
||||
// If the symbol isn't found or is invalid in the plugin an error will be
|
||||
// returned.
|
||||
func NewCredentials(p *plugin.Plugin) (*credentials.Credentials, error) {
|
||||
retrieve, isExpired, err := GetPluginProviderFns(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return credentials.NewCredentials(Provider{
|
||||
RetrieveFn: retrieve,
|
||||
IsExpiredFn: isExpired,
|
||||
}), nil
|
||||
}
|
||||
|
||||
// Retrieve will return the credentials Value if they were successfully retrieved
|
||||
// from the underlying plugin provider. An error will be returned otherwise.
|
||||
func (p Provider) Retrieve() (credentials.Value, error) {
|
||||
creds := credentials.Value{
|
||||
ProviderName: ProviderName,
|
||||
}
|
||||
|
||||
k, s, t, err := p.RetrieveFn()
|
||||
if err != nil {
|
||||
return creds, awserr.New(ErrCodePluginProviderRetrieve,
|
||||
"failed to retrieve credentials with plugin provider", err)
|
||||
}
|
||||
|
||||
creds.AccessKeyID = k
|
||||
creds.SecretAccessKey = s
|
||||
creds.SessionToken = t
|
||||
|
||||
return creds, nil
|
||||
}
|
||||
|
||||
// IsExpired will return the expired state of the underlying plugin provider.
|
||||
func (p Provider) IsExpired() bool {
|
||||
return p.IsExpiredFn()
|
||||
}
|
||||
|
||||
// GetPluginProviderFns returns the plugin's Retrieve and IsExpired functions
|
||||
// returned by the plugin's credential provider getter.
|
||||
//
|
||||
// Uses ProviderSymbolName as the symbol name when lookup up the symbol. If you
|
||||
// want to use a different symbol name, use GetPluginProviderFnsByName.
|
||||
func GetPluginProviderFns(p *plugin.Plugin) (func() (key, secret, token string, err error), func() bool, error) {
|
||||
return GetPluginProviderFnsByName(p, ProviderSymbolName)
|
||||
}
|
||||
|
||||
// GetPluginProviderFnsByName returns the plugin's Retrieve and IsExpired functions
|
||||
// returned by the plugin's credential provider getter.
|
||||
//
|
||||
// Same as GetPluginProviderFns, but takes a custom symbolName to lookup with.
|
||||
func GetPluginProviderFnsByName(p *plugin.Plugin, symbolName string) (func() (key, secret, token string, err error), func() bool, error) {
|
||||
sym, err := p.Lookup(symbolName)
|
||||
if err != nil {
|
||||
return nil, nil, awserr.New(ErrCodeLookupSymbolError,
|
||||
fmt.Sprintf("failed to lookup %s plugin provider symbol", symbolName), err)
|
||||
}
|
||||
|
||||
fn, ok := sym.(func() (func() (key, secret, token string, err error), func() bool))
|
||||
if !ok {
|
||||
return nil, nil, awserr.New(ErrCodeInvalidSymbolError,
|
||||
fmt.Sprintf("symbol %T, does not match the 'func() (func() (key, secret, token string, err error), func() bool)' type", sym), nil)
|
||||
}
|
||||
|
||||
retrieveFn, isExpiredFn := fn()
|
||||
if retrieveFn == nil {
|
||||
return nil, nil, awserr.New(ErrCodePluginRetrieveNil,
|
||||
"the plugin provider retrieve function cannot be nil", nil)
|
||||
}
|
||||
if isExpiredFn == nil {
|
||||
return nil, nil, awserr.New(ErrCodePluginIsExpiredNil,
|
||||
"the plugin provider isExpired function cannot be nil", nil)
|
||||
}
|
||||
|
||||
return retrieveFn, isExpiredFn, nil
|
||||
}
|
||||
+32
-2
@@ -9,6 +9,7 @@ package defaults
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -118,14 +119,43 @@ func RemoteCredProvider(cfg aws.Config, handlers request.Handlers) credentials.P
|
||||
return ec2RoleProvider(cfg, handlers)
|
||||
}
|
||||
|
||||
var lookupHostFn = net.LookupHost
|
||||
|
||||
func isLoopbackHost(host string) (bool, error) {
|
||||
ip := net.ParseIP(host)
|
||||
if ip != nil {
|
||||
return ip.IsLoopback(), nil
|
||||
}
|
||||
|
||||
// Host is not an ip, perform lookup
|
||||
addrs, err := lookupHostFn(host)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
if !net.ParseIP(addr).IsLoopback() {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func localHTTPCredProvider(cfg aws.Config, handlers request.Handlers, u string) credentials.Provider {
|
||||
var errMsg string
|
||||
|
||||
parsed, err := url.Parse(u)
|
||||
if err != nil {
|
||||
errMsg = fmt.Sprintf("invalid URL, %v", err)
|
||||
} else if host := aws.URLHostname(parsed); !(host == "localhost" || host == "127.0.0.1") {
|
||||
errMsg = fmt.Sprintf("invalid host address, %q, only localhost and 127.0.0.1 are valid.", host)
|
||||
} else {
|
||||
host := aws.URLHostname(parsed)
|
||||
if len(host) == 0 {
|
||||
errMsg = "unable to parse host from local HTTP cred provider URL"
|
||||
} else if isLoopback, loopbackErr := isLoopbackHost(host); loopbackErr != nil {
|
||||
errMsg = fmt.Sprintf("failed to resolve host %q, %v", host, loopbackErr)
|
||||
} else if !isLoopback {
|
||||
errMsg = fmt.Sprintf("invalid endpoint host, %q, only loopback hosts are allowed.", host)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errMsg) > 0 {
|
||||
|
||||
+326
-45
File diff suppressed because it is too large
Load Diff
+126
-22
@@ -24,10 +24,14 @@ const (
|
||||
// ErrCodeRead is an error that is returned during HTTP reads.
|
||||
ErrCodeRead = "ReadError"
|
||||
|
||||
// ErrCodeResponseTimeout is the connection timeout error that is recieved
|
||||
// ErrCodeResponseTimeout is the connection timeout error that is received
|
||||
// during body reads.
|
||||
ErrCodeResponseTimeout = "ResponseTimeout"
|
||||
|
||||
// ErrCodeInvalidPresignExpire is returned when the expire time provided to
|
||||
// presign is invalid
|
||||
ErrCodeInvalidPresignExpire = "InvalidPresignExpireError"
|
||||
|
||||
// CanceledErrorCode is the error code that will be returned by an
|
||||
// API request that was canceled. Requests given a aws.Context may
|
||||
// return this error when canceled.
|
||||
@@ -42,7 +46,6 @@ type Request struct {
|
||||
|
||||
Retryer
|
||||
Time time.Time
|
||||
ExpireTime time.Duration
|
||||
Operation *Operation
|
||||
HTTPRequest *http.Request
|
||||
HTTPResponse *http.Response
|
||||
@@ -60,6 +63,11 @@ type Request struct {
|
||||
LastSignedAt time.Time
|
||||
DisableFollowRedirects bool
|
||||
|
||||
// A value greater than 0 instructs the request to be signed as Presigned URL
|
||||
// You should not set this field directly. Instead use Request's
|
||||
// Presign or PresignRequest methods.
|
||||
ExpireTime time.Duration
|
||||
|
||||
context aws.Context
|
||||
|
||||
built bool
|
||||
@@ -104,6 +112,8 @@ func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers,
|
||||
err = awserr.New("InvalidEndpointURL", "invalid endpoint uri", err)
|
||||
}
|
||||
|
||||
SanitizeHostForHeader(httpReq)
|
||||
|
||||
r := &Request{
|
||||
Config: cfg,
|
||||
ClientInfo: clientInfo,
|
||||
@@ -250,34 +260,59 @@ func (r *Request) SetReaderBody(reader io.ReadSeeker) {
|
||||
|
||||
// Presign returns the request's signed URL. Error will be returned
|
||||
// if the signing fails.
|
||||
func (r *Request) Presign(expireTime time.Duration) (string, error) {
|
||||
r.ExpireTime = expireTime
|
||||
//
|
||||
// It is invalid to create a presigned URL with a expire duration 0 or less. An
|
||||
// error is returned if expire duration is 0 or less.
|
||||
func (r *Request) Presign(expire time.Duration) (string, error) {
|
||||
r = r.copy()
|
||||
|
||||
// Presign requires all headers be hoisted. There is no way to retrieve
|
||||
// the signed headers not hoisted without this. Making the presigned URL
|
||||
// useless.
|
||||
r.NotHoist = false
|
||||
|
||||
u, _, err := getPresignedURL(r, expire)
|
||||
return u, err
|
||||
}
|
||||
|
||||
// PresignRequest behaves just like presign, with the addition of returning a
|
||||
// set of headers that were signed.
|
||||
//
|
||||
// It is invalid to create a presigned URL with a expire duration 0 or less. An
|
||||
// error is returned if expire duration is 0 or less.
|
||||
//
|
||||
// Returns the URL string for the API operation with signature in the query string,
|
||||
// and the HTTP headers that were included in the signature. These headers must
|
||||
// be included in any HTTP request made with the presigned URL.
|
||||
//
|
||||
// To prevent hoisting any headers to the query string set NotHoist to true on
|
||||
// this Request value prior to calling PresignRequest.
|
||||
func (r *Request) PresignRequest(expire time.Duration) (string, http.Header, error) {
|
||||
r = r.copy()
|
||||
return getPresignedURL(r, expire)
|
||||
}
|
||||
|
||||
func getPresignedURL(r *Request, expire time.Duration) (string, http.Header, error) {
|
||||
if expire <= 0 {
|
||||
return "", nil, awserr.New(
|
||||
ErrCodeInvalidPresignExpire,
|
||||
"presigned URL requires an expire duration greater than 0",
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
r.ExpireTime = expire
|
||||
|
||||
if r.Operation.BeforePresignFn != nil {
|
||||
r = r.copy()
|
||||
err := r.Operation.BeforePresignFn(r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
if err := r.Operation.BeforePresignFn(r); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
|
||||
r.Sign()
|
||||
if r.Error != nil {
|
||||
return "", r.Error
|
||||
if err := r.Sign(); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return r.HTTPRequest.URL.String(), nil
|
||||
}
|
||||
|
||||
// PresignRequest behaves just like presign, but hoists all headers and signs them.
|
||||
// Also returns the signed hash back to the user
|
||||
func (r *Request) PresignRequest(expireTime time.Duration) (string, http.Header, error) {
|
||||
r.ExpireTime = expireTime
|
||||
r.NotHoist = true
|
||||
r.Sign()
|
||||
if r.Error != nil {
|
||||
return "", nil, r.Error
|
||||
}
|
||||
return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil
|
||||
}
|
||||
|
||||
@@ -573,3 +608,72 @@ func shouldRetryCancel(r *Request) bool {
|
||||
errStr != "net/http: request canceled while waiting for connection")
|
||||
|
||||
}
|
||||
|
||||
// SanitizeHostForHeader removes default port from host and updates request.Host
|
||||
func SanitizeHostForHeader(r *http.Request) {
|
||||
host := getHost(r)
|
||||
port := portOnly(host)
|
||||
if port != "" && isDefaultPort(r.URL.Scheme, port) {
|
||||
r.Host = stripPort(host)
|
||||
}
|
||||
}
|
||||
|
||||
// Returns host from request
|
||||
func getHost(r *http.Request) string {
|
||||
if r.Host != "" {
|
||||
return r.Host
|
||||
}
|
||||
|
||||
return r.URL.Host
|
||||
}
|
||||
|
||||
// Hostname returns u.Host, without any port number.
|
||||
//
|
||||
// If Host is an IPv6 literal with a port number, Hostname returns the
|
||||
// IPv6 literal without the square brackets. IPv6 literals may include
|
||||
// a zone identifier.
|
||||
//
|
||||
// Copied from the Go 1.8 standard library (net/url)
|
||||
func stripPort(hostport string) string {
|
||||
colon := strings.IndexByte(hostport, ':')
|
||||
if colon == -1 {
|
||||
return hostport
|
||||
}
|
||||
if i := strings.IndexByte(hostport, ']'); i != -1 {
|
||||
return strings.TrimPrefix(hostport[:i], "[")
|
||||
}
|
||||
return hostport[:colon]
|
||||
}
|
||||
|
||||
// Port returns the port part of u.Host, without the leading colon.
|
||||
// If u.Host doesn't contain a port, Port returns an empty string.
|
||||
//
|
||||
// Copied from the Go 1.8 standard library (net/url)
|
||||
func portOnly(hostport string) string {
|
||||
colon := strings.IndexByte(hostport, ':')
|
||||
if colon == -1 {
|
||||
return ""
|
||||
}
|
||||
if i := strings.Index(hostport, "]:"); i != -1 {
|
||||
return hostport[i+len("]:"):]
|
||||
}
|
||||
if strings.Contains(hostport, "]") {
|
||||
return ""
|
||||
}
|
||||
return hostport[colon+len(":"):]
|
||||
}
|
||||
|
||||
// Returns true if the specified URI is using the standard port
|
||||
// (i.e. port 80 for HTTP URIs or 443 for HTTPS URIs)
|
||||
func isDefaultPort(scheme, port string) bool {
|
||||
if port == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
lowerCaseScheme := strings.ToLower(scheme)
|
||||
if (lowerCaseScheme == "http" && port == "80") || (lowerCaseScheme == "https" && port == "443") {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
+2
-2
@@ -70,8 +70,8 @@ func isCodeExpiredCreds(code string) bool {
|
||||
}
|
||||
|
||||
var validParentCodes = map[string]struct{}{
|
||||
ErrCodeSerialization: struct{}{},
|
||||
ErrCodeRead: struct{}{},
|
||||
ErrCodeSerialization: {},
|
||||
ErrCodeRead: {},
|
||||
}
|
||||
|
||||
type temporaryError interface {
|
||||
|
||||
+5
-2
@@ -7,6 +7,9 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
)
|
||||
|
||||
// EnvProviderName provides a name of the provider when config is loaded from environment.
|
||||
const EnvProviderName = "EnvConfigCredentials"
|
||||
|
||||
// envConfig is a collection of environment values the SDK will read
|
||||
// setup config from. All environment values are optional. But some values
|
||||
// such as credentials require multiple values to be complete or the values
|
||||
@@ -76,7 +79,7 @@ type envConfig struct {
|
||||
SharedConfigFile string
|
||||
|
||||
// Sets the path to a custom Credentials Authroity (CA) Bundle PEM file
|
||||
// that the SDK will use instead of the the system's root CA bundle.
|
||||
// that the SDK will use instead of the system's root CA bundle.
|
||||
// Only use this if you want to configure the SDK to use a custom set
|
||||
// of CAs.
|
||||
//
|
||||
@@ -157,7 +160,7 @@ func envConfigLoad(enableSharedConfig bool) envConfig {
|
||||
if len(cfg.Creds.AccessKeyID) == 0 || len(cfg.Creds.SecretAccessKey) == 0 {
|
||||
cfg.Creds = credentials.Value{}
|
||||
} else {
|
||||
cfg.Creds.ProviderName = "EnvConfigCredentials"
|
||||
cfg.Creds.ProviderName = EnvProviderName
|
||||
}
|
||||
|
||||
regionKeys := regionEnvKeys
|
||||
|
||||
+5
@@ -43,6 +43,11 @@ role_arn = partial_assume_role_role_arn
|
||||
role_arn = assume_role_role_arn
|
||||
source_profile = complete_creds
|
||||
|
||||
[assume_role_w_mfa]
|
||||
role_arn = assume_role_role_arn
|
||||
source_profile = complete_creds
|
||||
mfa_serial = 0123456789
|
||||
|
||||
[assume_role_invalid_source_profile]
|
||||
role_arn = assume_role_invalid_source_profile_role_arn
|
||||
source_profile = profile_not_exists
|
||||
|
||||
+12
-6
@@ -268,7 +268,7 @@ type signingCtx struct {
|
||||
// "X-Amz-Content-Sha256" header with a precomputed value. The signer will
|
||||
// only compute the hash if the request header value is empty.
|
||||
func (v4 Signer) Sign(r *http.Request, body io.ReadSeeker, service, region string, signTime time.Time) (http.Header, error) {
|
||||
return v4.signWithBody(r, body, service, region, 0, signTime)
|
||||
return v4.signWithBody(r, body, service, region, 0, false, signTime)
|
||||
}
|
||||
|
||||
// Presign signs AWS v4 requests with the provided body, service name, region
|
||||
@@ -302,10 +302,10 @@ func (v4 Signer) Sign(r *http.Request, body io.ReadSeeker, service, region strin
|
||||
// presigned request's signature you can set the "X-Amz-Content-Sha256"
|
||||
// HTTP header and that will be included in the request's signature.
|
||||
func (v4 Signer) Presign(r *http.Request, body io.ReadSeeker, service, region string, exp time.Duration, signTime time.Time) (http.Header, error) {
|
||||
return v4.signWithBody(r, body, service, region, exp, signTime)
|
||||
return v4.signWithBody(r, body, service, region, exp, true, signTime)
|
||||
}
|
||||
|
||||
func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, region string, exp time.Duration, signTime time.Time) (http.Header, error) {
|
||||
func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, region string, exp time.Duration, isPresign bool, signTime time.Time) (http.Header, error) {
|
||||
currentTimeFn := v4.currentTimeFn
|
||||
if currentTimeFn == nil {
|
||||
currentTimeFn = time.Now
|
||||
@@ -317,7 +317,7 @@ func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, regi
|
||||
Query: r.URL.Query(),
|
||||
Time: signTime,
|
||||
ExpireTime: exp,
|
||||
isPresign: exp != 0,
|
||||
isPresign: isPresign,
|
||||
ServiceName: service,
|
||||
Region: region,
|
||||
DisableURIPathEscaping: v4.DisableURIPathEscaping,
|
||||
@@ -339,6 +339,7 @@ func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, regi
|
||||
return http.Header{}, err
|
||||
}
|
||||
|
||||
ctx.sanitizeHostForHeader()
|
||||
ctx.assignAmzQueryValues()
|
||||
ctx.build(v4.DisableHeaderHoisting)
|
||||
|
||||
@@ -363,6 +364,10 @@ func (v4 Signer) signWithBody(r *http.Request, body io.ReadSeeker, service, regi
|
||||
return ctx.SignedHeaderVals, nil
|
||||
}
|
||||
|
||||
func (ctx *signingCtx) sanitizeHostForHeader() {
|
||||
request.SanitizeHostForHeader(ctx.Request)
|
||||
}
|
||||
|
||||
func (ctx *signingCtx) handlePresignRemoval() {
|
||||
if !ctx.isPresign {
|
||||
return
|
||||
@@ -467,7 +472,7 @@ func signSDKRequestWithCurrTime(req *request.Request, curTimeFn func() time.Time
|
||||
}
|
||||
|
||||
signedHeaders, err := v4.signWithBody(req.HTTPRequest, req.GetBody(),
|
||||
name, region, req.ExpireTime, signingTime,
|
||||
name, region, req.ExpireTime, req.ExpireTime > 0, signingTime,
|
||||
)
|
||||
if err != nil {
|
||||
req.Error = err
|
||||
@@ -502,6 +507,8 @@ func (ctx *signingCtx) build(disableHeaderHoisting bool) {
|
||||
ctx.buildTime() // no depends
|
||||
ctx.buildCredentialString() // no depends
|
||||
|
||||
ctx.buildBodyDigest()
|
||||
|
||||
unsignedHeaders := ctx.Request.Header
|
||||
if ctx.isPresign {
|
||||
if !disableHeaderHoisting {
|
||||
@@ -513,7 +520,6 @@ func (ctx *signingCtx) build(disableHeaderHoisting bool) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.buildBodyDigest()
|
||||
ctx.buildCanonicalHeaders(ignoredHeaders, unsignedHeaders)
|
||||
ctx.buildCanonicalString() // depends on canon headers / signed headers
|
||||
ctx.buildStringToSign() // depends on canon string
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ package aws
|
||||
const SDKName = "aws-sdk-go"
|
||||
|
||||
// SDKVersion is the version of this SDK
|
||||
const SDKVersion = "1.10.18"
|
||||
const SDKVersion = "1.12.65"
|
||||
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"ImportPath": "github.com/aws/aws-sdk-go/awsmigrate/awsmigrate-renamer",
|
||||
"GoVersion": "go1.6",
|
||||
"GodepVersion": "v60",
|
||||
"Deps": [
|
||||
{
|
||||
"ImportPath": "golang.org/x/tools/go/ast/astutil",
|
||||
"Rev": "b75b3f5cd5d50fbb1fb88ce784d2e7cca17bba8a"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/tools/go/buildutil",
|
||||
"Rev": "b75b3f5cd5d50fbb1fb88ce784d2e7cca17bba8a"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/tools/go/loader",
|
||||
"Rev": "b75b3f5cd5d50fbb1fb88ce784d2e7cca17bba8a"
|
||||
}
|
||||
]
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
This directory tree is generated automatically by godep.
|
||||
|
||||
Please do not edit.
|
||||
|
||||
See https://github.com/tools/godep for more information.
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
// +build go1.5,deprecated
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go/format"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/aws/aws-sdk-go/private/model/api"
|
||||
)
|
||||
|
||||
type pkg struct {
|
||||
oldAPI *api.API
|
||||
newAPI *api.API
|
||||
shapes map[string]*shapentry
|
||||
operations map[string]*opentry
|
||||
}
|
||||
|
||||
type shapentry struct {
|
||||
oldShape *api.Shape
|
||||
newShape *api.Shape
|
||||
}
|
||||
|
||||
type opentry struct {
|
||||
oldName string
|
||||
newName string
|
||||
}
|
||||
|
||||
type packageRenames struct {
|
||||
Shapes map[string]string
|
||||
Operations map[string]string
|
||||
Fields map[string]string
|
||||
}
|
||||
|
||||
var exportMap = map[string]*packageRenames{}
|
||||
|
||||
func generateRenames(w io.Writer) error {
|
||||
tmpl, err := template.New("renames").Parse(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out := bytes.NewBuffer(nil)
|
||||
if err = tmpl.Execute(out, exportMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err := format.Source(bytes.TrimSpace(out.Bytes()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(w, bytes.NewReader(b))
|
||||
return err
|
||||
}
|
||||
|
||||
const t = `
|
||||
package rename
|
||||
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
|
||||
var renamedPackages = map[string]*packageRenames{
|
||||
{{ range $key, $entry := . }}"{{ $key }}": &packageRenames{
|
||||
operations: map[string]string{
|
||||
{{ range $old, $new := $entry.Operations }}"{{ $old }}": "{{ $new }}",
|
||||
{{ end }}
|
||||
},
|
||||
shapes: map[string]string{
|
||||
{{ range $old, $new := $entry.Shapes }}"{{ $old }}": "{{ $new }}",
|
||||
{{ end }}
|
||||
},
|
||||
fields: map[string]string{
|
||||
{{ range $old, $new := $entry.Fields }}"{{ $old }}": "{{ $new }}",
|
||||
{{ end }}
|
||||
},
|
||||
},
|
||||
{{ end }}
|
||||
}
|
||||
`
|
||||
|
||||
func (p *pkg) buildRenames() {
|
||||
pkgName := "github.com/aws/aws-sdk-go/service/" + p.oldAPI.PackageName()
|
||||
if exportMap[pkgName] == nil {
|
||||
exportMap[pkgName] = &packageRenames{map[string]string{}, map[string]string{}, map[string]string{}}
|
||||
}
|
||||
ifacename := "github.com/aws/aws-sdk-go/service/" + p.oldAPI.PackageName() + "/" +
|
||||
p.oldAPI.InterfacePackageName()
|
||||
if exportMap[ifacename] == nil {
|
||||
exportMap[ifacename] = &packageRenames{map[string]string{}, map[string]string{}, map[string]string{}}
|
||||
}
|
||||
|
||||
for _, entry := range p.operations {
|
||||
if entry.oldName != entry.newName {
|
||||
pkgNames := []string{pkgName, ifacename}
|
||||
for _, p := range pkgNames {
|
||||
exportMap[p].Operations[entry.oldName] = entry.newName
|
||||
exportMap[p].Operations[entry.oldName+"Request"] = entry.newName + "Request"
|
||||
exportMap[p].Operations[entry.oldName+"Pages"] = entry.newName + "Pages"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, entry := range p.shapes {
|
||||
if entry.oldShape.Type == "structure" {
|
||||
if entry.oldShape.ShapeName != entry.newShape.ShapeName {
|
||||
exportMap[pkgName].Shapes[entry.oldShape.ShapeName] = entry.newShape.ShapeName
|
||||
}
|
||||
|
||||
for _, n := range entry.oldShape.MemberNames() {
|
||||
for _, m := range entry.newShape.MemberNames() {
|
||||
if n != m && strings.ToLower(n) == strings.ToLower(m) {
|
||||
exportMap[pkgName].Fields[n] = m
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func load(file string) *pkg {
|
||||
p := &pkg{&api.API{}, &api.API{}, map[string]*shapentry{}, map[string]*opentry{}}
|
||||
|
||||
p.oldAPI.Attach(file)
|
||||
p.oldAPI.Setup()
|
||||
|
||||
p.newAPI.Attach(file)
|
||||
p.newAPI.Setup()
|
||||
|
||||
for _, name := range p.oldAPI.OperationNames() {
|
||||
p.operations[strings.ToLower(name)] = &opentry{oldName: name}
|
||||
}
|
||||
|
||||
for _, name := range p.newAPI.OperationNames() {
|
||||
p.operations[strings.ToLower(name)].newName = name
|
||||
}
|
||||
|
||||
for _, shape := range p.oldAPI.ShapeList() {
|
||||
p.shapes[strings.ToLower(shape.ShapeName)] = &shapentry{oldShape: shape}
|
||||
}
|
||||
|
||||
for _, shape := range p.newAPI.ShapeList() {
|
||||
if _, ok := p.shapes[strings.ToLower(shape.ShapeName)]; !ok {
|
||||
panic("missing shape " + shape.ShapeName)
|
||||
}
|
||||
p.shapes[strings.ToLower(shape.ShapeName)].newShape = shape
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
var excludeServices = map[string]struct{}{
|
||||
"simpledb": {},
|
||||
"importexport": {},
|
||||
}
|
||||
|
||||
func main() {
|
||||
files, _ := filepath.Glob("../../apis/*/*/api-2.json")
|
||||
|
||||
sort.Strings(files)
|
||||
|
||||
// Remove old API versions from list
|
||||
m := map[string]bool{}
|
||||
for i := range files {
|
||||
idx := len(files) - 1 - i
|
||||
parts := strings.Split(files[idx], string(filepath.Separator))
|
||||
svc := parts[len(parts)-3] // service name is 2nd-to-last component
|
||||
|
||||
if m[svc] {
|
||||
files[idx] = "" // wipe this one out if we already saw the service
|
||||
}
|
||||
m[svc] = true
|
||||
}
|
||||
|
||||
for i := range files {
|
||||
file := files[i]
|
||||
if file == "" { // empty file
|
||||
continue
|
||||
}
|
||||
|
||||
if g := load(file); g != nil {
|
||||
if _, ok := excludeServices[g.oldAPI.PackageName()]; !ok {
|
||||
g.buildRenames()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outfile, err := os.Create("rename/renames.go")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := generateRenames(outfile); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
// +build go1.5,deprecated
|
||||
|
||||
package rename
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
|
||||
"golang.org/x/tools/go/loader"
|
||||
)
|
||||
|
||||
var dryRun = flag.Bool("dryrun", false, "Dry run")
|
||||
var verbose = flag.Bool("verbose", false, "Verbose")
|
||||
|
||||
type packageRenames struct {
|
||||
operations map[string]string
|
||||
shapes map[string]string
|
||||
fields map[string]string
|
||||
}
|
||||
|
||||
type renamer struct {
|
||||
*loader.Program
|
||||
files map[*token.File]bool
|
||||
}
|
||||
|
||||
// ParsePathsFromArgs parses arguments from command line and looks at import
|
||||
// paths to rename objects.
|
||||
func ParsePathsFromArgs() {
|
||||
flag.Parse()
|
||||
for _, dir := range flag.Args() {
|
||||
var conf loader.Config
|
||||
conf.ParserMode = parser.ParseComments
|
||||
conf.ImportWithTests(dir)
|
||||
prog, err := conf.Load()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
r := renamer{prog, map[*token.File]bool{}}
|
||||
r.parse()
|
||||
if !*dryRun {
|
||||
r.write()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (r *renamer) dryInfo() string {
|
||||
if *dryRun {
|
||||
return "[DRY-RUN]"
|
||||
}
|
||||
return "[!]"
|
||||
}
|
||||
|
||||
func (r *renamer) printf(msg string, args ...interface{}) {
|
||||
if *verbose {
|
||||
fmt.Printf(msg, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *renamer) parse() {
|
||||
for _, pkg := range r.InitialPackages() {
|
||||
r.parseUses(pkg)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *renamer) write() {
|
||||
for _, pkg := range r.InitialPackages() {
|
||||
for _, f := range pkg.Files {
|
||||
tokenFile := r.Fset.File(f.Pos())
|
||||
if r.files[tokenFile] {
|
||||
var buf bytes.Buffer
|
||||
format.Node(&buf, r.Fset, f)
|
||||
if err := ioutil.WriteFile(tokenFile.Name(), buf.Bytes(), 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (r *renamer) parseUses(pkg *loader.PackageInfo) {
|
||||
for k, v := range pkg.Uses {
|
||||
if v.Pkg() != nil {
|
||||
pkgPath := v.Pkg().Path()
|
||||
if renames, ok := renamedPackages[pkgPath]; ok {
|
||||
name := k.Name
|
||||
switch t := v.(type) {
|
||||
case *types.Func:
|
||||
if newName, ok := renames.operations[t.Name()]; ok && newName != name {
|
||||
r.printf("%s Rename [OPERATION]: %q -> %q\n", r.dryInfo(), name, newName)
|
||||
r.files[r.Fset.File(k.Pos())] = true
|
||||
k.Name = newName
|
||||
}
|
||||
case *types.TypeName:
|
||||
if newName, ok := renames.shapes[name]; ok && newName != name {
|
||||
r.printf("%s Rename [SHAPE]: %q -> %q\n", r.dryInfo(), t.Name(), newName)
|
||||
r.files[r.Fset.File(k.Pos())] = true
|
||||
k.Name = newName
|
||||
}
|
||||
case *types.Var:
|
||||
if newName, ok := renames.fields[name]; ok && newName != name {
|
||||
r.printf("%s Rename [FIELD]: %q -> %q\n", r.dryInfo(), t.Name(), newName)
|
||||
r.files[r.Fset.File(k.Pos())] = true
|
||||
k.Name = newName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2120
File diff suppressed because it is too large
Load Diff
+45
@@ -0,0 +1,45 @@
|
||||
// +build go1.5,deprecated
|
||||
|
||||
package main
|
||||
|
||||
//go:generate go run -tags deprecated gen/gen.go
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/awsmigrate/awsmigrate-renamer/rename"
|
||||
)
|
||||
|
||||
var safeTag = "4e554f77f00d527b452c68a46f2e68595284121b"
|
||||
|
||||
func main() {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
if gopath == "" {
|
||||
panic("GOPATH not set!")
|
||||
}
|
||||
gopath = strings.Split(gopath, ":")[0]
|
||||
|
||||
// change directory to SDK
|
||||
err := os.Chdir(filepath.Join(gopath, "src", "github.com", "aws", "aws-sdk-go"))
|
||||
if err != nil {
|
||||
panic("Cannot find SDK repository")
|
||||
}
|
||||
|
||||
// store orig HEAD
|
||||
head, err := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output()
|
||||
if err != nil {
|
||||
panic("Cannot find SDK repository")
|
||||
}
|
||||
origHEAD := strings.Trim(string(head), " \r\n")
|
||||
|
||||
// checkout to safe tag and run conversion
|
||||
exec.Command("git", "checkout", safeTag).Run()
|
||||
defer func() {
|
||||
exec.Command("git", "checkout", origHEAD).Run()
|
||||
}()
|
||||
|
||||
rename.ParsePathsFromArgs()
|
||||
}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
package awstesting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Match is a testing helper to test for testing error by comparing expected
|
||||
// with a regular expression.
|
||||
func Match(t *testing.T, regex, expected string) {
|
||||
if !regexp.MustCompile(regex).Match([]byte(expected)) {
|
||||
t.Errorf("%q\n\tdoes not match /%s/", expected, regex)
|
||||
}
|
||||
}
|
||||
|
||||
// AssertURL verifies the expected URL is matches the actual.
|
||||
func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool {
|
||||
expectURL, err := url.Parse(expect)
|
||||
if err != nil {
|
||||
t.Errorf(errMsg("unable to parse expected URL", err, msgAndArgs))
|
||||
return false
|
||||
}
|
||||
actualURL, err := url.Parse(actual)
|
||||
if err != nil {
|
||||
t.Errorf(errMsg("unable to parse actual URL", err, msgAndArgs))
|
||||
return false
|
||||
}
|
||||
|
||||
equal(t, expectURL.Host, actualURL.Host, msgAndArgs...)
|
||||
equal(t, expectURL.Scheme, actualURL.Scheme, msgAndArgs...)
|
||||
equal(t, expectURL.Path, actualURL.Path, msgAndArgs...)
|
||||
|
||||
return AssertQuery(t, expectURL.Query().Encode(), actualURL.Query().Encode(), msgAndArgs...)
|
||||
}
|
||||
|
||||
var queryMapKey = regexp.MustCompile("(.*?)\\.[0-9]+\\.key")
|
||||
|
||||
// AssertQuery verifies the expect HTTP query string matches the actual.
|
||||
func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool {
|
||||
expectQ, err := url.ParseQuery(expect)
|
||||
if err != nil {
|
||||
t.Errorf(errMsg("unable to parse expected Query", err, msgAndArgs))
|
||||
return false
|
||||
}
|
||||
actualQ, err := url.ParseQuery(actual)
|
||||
if err != nil {
|
||||
t.Errorf(errMsg("unable to parse actual Query", err, msgAndArgs))
|
||||
return false
|
||||
}
|
||||
|
||||
// Make sure the keys are the same
|
||||
if !equal(t, queryValueKeys(expectQ), queryValueKeys(actualQ), msgAndArgs...) {
|
||||
return false
|
||||
}
|
||||
|
||||
keys := map[string][]string{}
|
||||
for key, v := range expectQ {
|
||||
if queryMapKey.Match([]byte(key)) {
|
||||
submatch := queryMapKey.FindStringSubmatch(key)
|
||||
keys[submatch[1]] = append(keys[submatch[1]], v...)
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range keys {
|
||||
// clear all keys that have prefix
|
||||
for key := range expectQ {
|
||||
if strings.HasPrefix(key, k) {
|
||||
delete(expectQ, key)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(v)
|
||||
for i, value := range v {
|
||||
expectQ[fmt.Sprintf("%s.%d.key", k, i+1)] = []string{value}
|
||||
}
|
||||
}
|
||||
|
||||
for k, expectQVals := range expectQ {
|
||||
sort.Strings(expectQVals)
|
||||
actualQVals := actualQ[k]
|
||||
sort.Strings(actualQVals)
|
||||
if !equal(t, expectQVals, actualQVals, msgAndArgs...) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// AssertJSON verifies that the expect json string matches the actual.
|
||||
func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool {
|
||||
expectVal := map[string]interface{}{}
|
||||
if err := json.Unmarshal([]byte(expect), &expectVal); err != nil {
|
||||
t.Errorf(errMsg("unable to parse expected JSON", err, msgAndArgs...))
|
||||
return false
|
||||
}
|
||||
|
||||
actualVal := map[string]interface{}{}
|
||||
if err := json.Unmarshal([]byte(actual), &actualVal); err != nil {
|
||||
t.Errorf(errMsg("unable to parse actual JSON", err, msgAndArgs...))
|
||||
return false
|
||||
}
|
||||
|
||||
return equal(t, expectVal, actualVal, msgAndArgs...)
|
||||
}
|
||||
|
||||
// AssertXML verifies that the expect xml string matches the actual.
|
||||
func AssertXML(t *testing.T, expect, actual string, container interface{}, msgAndArgs ...interface{}) bool {
|
||||
expectVal := container
|
||||
if err := xml.Unmarshal([]byte(expect), &expectVal); err != nil {
|
||||
t.Errorf(errMsg("unable to parse expected XML", err, msgAndArgs...))
|
||||
}
|
||||
|
||||
actualVal := container
|
||||
if err := xml.Unmarshal([]byte(actual), &actualVal); err != nil {
|
||||
t.Errorf(errMsg("unable to parse actual XML", err, msgAndArgs...))
|
||||
}
|
||||
return equal(t, expectVal, actualVal, msgAndArgs...)
|
||||
}
|
||||
|
||||
// DidPanic returns if the function paniced and returns true if the function paniced.
|
||||
func DidPanic(fn func()) (bool, interface{}) {
|
||||
var paniced bool
|
||||
var msg interface{}
|
||||
func() {
|
||||
defer func() {
|
||||
if msg = recover(); msg != nil {
|
||||
paniced = true
|
||||
}
|
||||
}()
|
||||
fn()
|
||||
}()
|
||||
|
||||
return paniced, msg
|
||||
}
|
||||
|
||||
// objectsAreEqual determines if two objects are considered equal.
|
||||
//
|
||||
// This function does no assertion of any kind.
|
||||
//
|
||||
// Based on github.com/stretchr/testify/assert.ObjectsAreEqual
|
||||
// Copied locally to prevent non-test build dependencies on testify
|
||||
func objectsAreEqual(expected, actual interface{}) bool {
|
||||
if expected == nil || actual == nil {
|
||||
return expected == actual
|
||||
}
|
||||
|
||||
return reflect.DeepEqual(expected, actual)
|
||||
}
|
||||
|
||||
// Equal asserts that two objects are equal.
|
||||
//
|
||||
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
||||
//
|
||||
// Returns whether the assertion was successful (true) or not (false).
|
||||
//
|
||||
// Based on github.com/stretchr/testify/assert.Equal
|
||||
// Copied locally to prevent non-test build dependencies on testify
|
||||
func equal(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||
if !objectsAreEqual(expected, actual) {
|
||||
t.Errorf("%s\n%s", messageFromMsgAndArgs(msgAndArgs),
|
||||
SprintExpectActual(expected, actual))
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func errMsg(baseMsg string, err error, msgAndArgs ...interface{}) string {
|
||||
message := messageFromMsgAndArgs(msgAndArgs)
|
||||
if message != "" {
|
||||
message += ", "
|
||||
}
|
||||
return fmt.Sprintf("%s%s, %v", message, baseMsg, err)
|
||||
}
|
||||
|
||||
// Based on github.com/stretchr/testify/assert.messageFromMsgAndArgs
|
||||
// Copied locally to prevent non-test build dependencies on testify
|
||||
func messageFromMsgAndArgs(msgAndArgs []interface{}) string {
|
||||
if len(msgAndArgs) == 0 || msgAndArgs == nil {
|
||||
return ""
|
||||
}
|
||||
if len(msgAndArgs) == 1 {
|
||||
return msgAndArgs[0].(string)
|
||||
}
|
||||
if len(msgAndArgs) > 1 {
|
||||
return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func queryValueKeys(v url.Values) []string {
|
||||
keys := make([]string, 0, len(v))
|
||||
for k := range v {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
// SprintExpectActual returns a string for test failure cases when the actual
|
||||
// value is not the same as the expected.
|
||||
func SprintExpectActual(expect, actual interface{}) string {
|
||||
return fmt.Sprintf("expect: %+v\nactual: %+v\n", expect, actual)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package awstesting
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/defaults"
|
||||
)
|
||||
|
||||
// NewClient creates and initializes a generic service client for testing.
|
||||
func NewClient(cfgs ...*aws.Config) *client.Client {
|
||||
info := metadata.ClientInfo{
|
||||
Endpoint: "http://endpoint",
|
||||
SigningName: "",
|
||||
}
|
||||
def := defaults.Get()
|
||||
def.Config.MergeIn(cfgs...)
|
||||
|
||||
if v := aws.StringValue(def.Config.Endpoint); len(v) > 0 {
|
||||
info.Endpoint = v
|
||||
}
|
||||
|
||||
return client.New(*def.Config, info, def.Handlers)
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
// +build integration
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
// Searches the buckets of an account that match the prefix, and deletes
|
||||
// those buckets, and all objects within. Before deleting will prompt user
|
||||
// to confirm bucket should be deleted. Positive confirmation is required.
|
||||
//
|
||||
// Usage:
|
||||
// go run deleteBuckets.go <bucketPrefix>
|
||||
func main() {
|
||||
sess := session.Must(session.NewSession())
|
||||
|
||||
svc := s3.New(sess)
|
||||
buckets, err := svc.ListBuckets(&s3.ListBucketsInput{})
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to list buckets, %v", err))
|
||||
}
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintln(os.Stderr, "bucket prefix required")
|
||||
os.Exit(1)
|
||||
}
|
||||
bucketPrefix := os.Args[1]
|
||||
|
||||
var failed bool
|
||||
for _, b := range buckets.Buckets {
|
||||
bucket := aws.StringValue(b.Name)
|
||||
|
||||
if !strings.HasPrefix(bucket, bucketPrefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("Delete bucket %q? [y/N]: ", bucket)
|
||||
var v string
|
||||
if _, err := fmt.Scanln(&v); err != nil || !(v == "Y" || v == "y") {
|
||||
fmt.Println("\tSkipping")
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println("\tDeleting")
|
||||
if err := deleteBucket(svc, bucket); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to delete bucket %q, %v", bucket, err)
|
||||
failed = true
|
||||
}
|
||||
}
|
||||
|
||||
if failed {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func deleteBucket(svc *s3.S3, bucket string) error {
|
||||
bucketName := &bucket
|
||||
|
||||
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
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
package awstesting
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func availableLocalAddr(ip string) (string, error) {
|
||||
l, err := net.Listen("tcp", ip+":0")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
return l.Addr().String(), nil
|
||||
}
|
||||
|
||||
// CreateTLSServer will create the TLS server on an open port using the
|
||||
// certificate and key. The address will be returned that the server is running on.
|
||||
func CreateTLSServer(cert, key string, mux *http.ServeMux) (string, error) {
|
||||
addr, err := availableLocalAddr("127.0.0.1")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if mux == nil {
|
||||
mux = http.NewServeMux()
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {})
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := http.ListenAndServeTLS(addr, cert, key, mux); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
for i := 0; i < 60; i++ {
|
||||
if _, err := http.Get("https://" + addr); err != nil && !strings.Contains(err.Error(), "connection refused") {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
return "https://" + addr, nil
|
||||
}
|
||||
|
||||
// CreateTLSBundleFiles returns the temporary filenames for the certificate
|
||||
// key, and CA PEM content. These files should be deleted when no longer
|
||||
// needed. CleanupTLSBundleFiles can be used for this cleanup.
|
||||
func CreateTLSBundleFiles() (cert, key, ca string, err error) {
|
||||
cert, err = createTmpFile(TLSBundleCert)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
key, err = createTmpFile(TLSBundleKey)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
ca, err = createTmpFile(TLSBundleCA)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
return cert, key, ca, nil
|
||||
}
|
||||
|
||||
// CleanupTLSBundleFiles takes variadic list of files to be deleted.
|
||||
func CleanupTLSBundleFiles(files ...string) error {
|
||||
for _, file := range files {
|
||||
if err := os.Remove(file); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createTmpFile(b []byte) (string, error) {
|
||||
bundleFile, err := ioutil.TempFile(os.TempDir(), "aws-sdk-go-session-test")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, err = bundleFile.Write(b)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer bundleFile.Close()
|
||||
return bundleFile.Name(), nil
|
||||
}
|
||||
|
||||
/* Cert generation steps
|
||||
# Create the CA key
|
||||
openssl genrsa -des3 -out ca.key 1024
|
||||
|
||||
# Create the CA Cert
|
||||
openssl req -new -sha256 -x509 -days 3650 \
|
||||
-subj "/C=GO/ST=Gopher/O=Testing ROOT CA" \
|
||||
-key ca.key -out ca.crt
|
||||
|
||||
# Create config
|
||||
cat > csr_details.txt <<-EOF
|
||||
|
||||
[req]
|
||||
default_bits = 1024
|
||||
prompt = no
|
||||
default_md = sha256
|
||||
req_extensions = SAN
|
||||
distinguished_name = dn
|
||||
|
||||
[ dn ]
|
||||
C=GO
|
||||
ST=Gopher
|
||||
O=Testing Certificate
|
||||
OU=Testing IP
|
||||
|
||||
[SAN]
|
||||
subjectAltName = IP:127.0.0.1
|
||||
EOF
|
||||
|
||||
# Create certificate signing request
|
||||
openssl req -new -sha256 -nodes -newkey rsa:1024 \
|
||||
-config <( cat csr_details.txt ) \
|
||||
-keyout ia.key -out ia.csr
|
||||
|
||||
# Create a signed certificate
|
||||
openssl x509 -req -days 3650 \
|
||||
-CAcreateserial \
|
||||
-extfile <( cat csr_details.txt ) \
|
||||
-extensions SAN \
|
||||
-CA ca.crt -CAkey ca.key -in ia.csr -out ia.crt
|
||||
|
||||
# Verify
|
||||
openssl req -noout -text -in ia.csr
|
||||
openssl x509 -noout -text -in ia.crt
|
||||
*/
|
||||
var (
|
||||
// TLSBundleCA ca.crt
|
||||
TLSBundleCA = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIICiTCCAfKgAwIBAgIJAJ5X1olt05XjMA0GCSqGSIb3DQEBCwUAMDgxCzAJBgNV
|
||||
BAYTAkdPMQ8wDQYDVQQIEwZHb3BoZXIxGDAWBgNVBAoTD1Rlc3RpbmcgUk9PVCBD
|
||||
QTAeFw0xNzAzMDkwMDAyMDZaFw0yNzAzMDcwMDAyMDZaMDgxCzAJBgNVBAYTAkdP
|
||||
MQ8wDQYDVQQIEwZHb3BoZXIxGDAWBgNVBAoTD1Rlc3RpbmcgUk9PVCBDQTCBnzAN
|
||||
BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAw/8DN+t9XQR60jx42rsQ2WE2Dx85rb3n
|
||||
GQxnKZZLNddsT8rDyxJNP18aFalbRbFlyln5fxWxZIblu9Xkm/HRhOpbSimSqo1y
|
||||
uDx21NVZ1YsOvXpHby71jx3gPrrhSc/t/zikhi++6D/C6m1CiIGuiJ0GBiJxtrub
|
||||
UBMXT0QtI2ECAwEAAaOBmjCBlzAdBgNVHQ4EFgQU8XG3X/YHBA6T04kdEkq6+4GV
|
||||
YykwaAYDVR0jBGEwX4AU8XG3X/YHBA6T04kdEkq6+4GVYymhPKQ6MDgxCzAJBgNV
|
||||
BAYTAkdPMQ8wDQYDVQQIEwZHb3BoZXIxGDAWBgNVBAoTD1Rlc3RpbmcgUk9PVCBD
|
||||
QYIJAJ5X1olt05XjMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEAeILv
|
||||
z49+uxmPcfOZzonuOloRcpdvyjiXblYxbzz6ch8GsE7Q886FTZbvwbgLhzdwSVgG
|
||||
G8WHkodDUsymVepdqAamS3f8PdCUk8xIk9mop8LgaB9Ns0/TssxDvMr3sOD2Grb3
|
||||
xyWymTWMcj6uCiEBKtnUp4rPiefcvCRYZ17/hLE=
|
||||
-----END CERTIFICATE-----
|
||||
`)
|
||||
|
||||
// TLSBundleCert ai.crt
|
||||
TLSBundleCert = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIICGjCCAYOgAwIBAgIJAIIu+NOoxxM0MA0GCSqGSIb3DQEBBQUAMDgxCzAJBgNV
|
||||
BAYTAkdPMQ8wDQYDVQQIEwZHb3BoZXIxGDAWBgNVBAoTD1Rlc3RpbmcgUk9PVCBD
|
||||
QTAeFw0xNzAzMDkwMDAzMTRaFw0yNzAzMDcwMDAzMTRaMFExCzAJBgNVBAYTAkdP
|
||||
MQ8wDQYDVQQIDAZHb3BoZXIxHDAaBgNVBAoME1Rlc3RpbmcgQ2VydGlmaWNhdGUx
|
||||
EzARBgNVBAsMClRlc3RpbmcgSVAwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
||||
AN1hWHeioo/nASvbrjwCQzXCiWiEzGkw353NxsAB54/NqDL3LXNATtiSJu8kJBrm
|
||||
Ah12IFLtWLGXjGjjYlHbQWnOR6awveeXnQZukJyRWh7m/Qlt9Ho0CgZE1U+832ac
|
||||
5GWVldNxW1Lz4I+W9/ehzqe8I80RS6eLEKfUFXGiW+9RAgMBAAGjEzARMA8GA1Ud
|
||||
EQQIMAaHBH8AAAEwDQYJKoZIhvcNAQEFBQADgYEAdF4WQHfVdPCbgv9sxgJjcR1H
|
||||
Hgw9rZ47gO1IiIhzglnLXQ6QuemRiHeYFg4kjcYBk1DJguxzDTGnUwhUXOibAB+S
|
||||
zssmrkdYYvn9aUhjc3XK3tjAoDpsPpeBeTBamuUKDHoH/dNRXxerZ8vu6uPR3Pgs
|
||||
5v/KCV6IAEcvNyOXMPo=
|
||||
-----END CERTIFICATE-----
|
||||
`)
|
||||
|
||||
// TLSBundleKey ai.key
|
||||
TLSBundleKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQDdYVh3oqKP5wEr2648AkM1wolohMxpMN+dzcbAAeePzagy9y1z
|
||||
QE7YkibvJCQa5gIddiBS7Vixl4xo42JR20FpzkemsL3nl50GbpCckVoe5v0JbfR6
|
||||
NAoGRNVPvN9mnORllZXTcVtS8+CPlvf3oc6nvCPNEUunixCn1BVxolvvUQIDAQAB
|
||||
AoGBAMISrcirddGrlLZLLrKC1ULS2T0cdkqdQtwHYn4+7S5+/z42vMx1iumHLsSk
|
||||
rVY7X41OWkX4trFxhvEIrc/O48bo2zw78P7flTxHy14uxXnllU8cLThE29SlUU7j
|
||||
AVBNxJZMsXMlS/DowwD4CjFe+x4Pu9wZcReF2Z9ntzMpySABAkEA+iWoJCPE2JpS
|
||||
y78q3HYYgpNY3gF3JqQ0SI/zTNkb3YyEIUffEYq0Y9pK13HjKtdsSuX4osTIhQkS
|
||||
+UgRp6tCAQJBAOKPYTfQ2FX8ijgUpHZRuEAVaxASAS0UATiLgzXxLvOh/VC2at5x
|
||||
wjOX6sD65pPz/0D8Qj52Cq6Q1TQ+377SDVECQAIy0od+yPweXxvrUjUd1JlRMjbB
|
||||
TIrKZqs8mKbUQapw0bh5KTy+O1elU4MRPS3jNtBxtP25PQnuSnxmZcFTgAECQFzg
|
||||
DiiFcsn9FuRagfkHExMiNJuH5feGxeFaP9WzI144v9GAllrOI6Bm3JNzx2ZLlg4b
|
||||
20Qju8lIEj6yr6JYFaECQHM1VSojGRKpOl9Ox/R4yYSA9RV5Gyn00/aJNxVYyPD5
|
||||
i3acL2joQm2kLD/LO8paJ4+iQdRXCOMMIpjxSNjGQjQ=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
`)
|
||||
)
|
||||
Generated
Vendored
+29
@@ -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)
|
||||
})
|
||||
}
|
||||
vendor/github.com/aws/aws-sdk-go/awstesting/integration/customizations/s3/s3crypto/s3_crypto.feature
Generated
Vendored
+33
@@ -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
|
||||
Generated
Vendored
+211
@@ -0,0 +1,211 @@
|
||||
// +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/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),
|
||||
})
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect no error, got %v", 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,
|
||||
})
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect no error, got %v", err)
|
||||
}
|
||||
caseKey := strings.TrimPrefix(*plaintextKey, baseFolder+"/"+prefix)
|
||||
plaintext, err := ioutil.ReadAll(ptObj.Body)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect no error, got %v", 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,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect no error, got %v", err)
|
||||
}
|
||||
|
||||
ciphertext, err := ioutil.ReadAll(ctObj.Body)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect no error, got %v", 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 {
|
||||
if e, a := len(plaintexts[caseKey]), len(ciphertext); e != a {
|
||||
gucumber.T.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := plaintexts[caseKey], ciphertext; !bytes.Equal(e, a) {
|
||||
gucumber.T.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect nil, got %v", nil)
|
||||
}
|
||||
|
||||
b64Arn := base64.StdEncoding.EncodeToString([]byte(arn))
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect nil, got %v", nil)
|
||||
}
|
||||
gucumber.World["Masterkey"] = b64Arn
|
||||
|
||||
handler = s3crypto.NewKMSKeyGenerator(kms.New(session.New(&aws.Config{
|
||||
Region: &v2,
|
||||
})), arn)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect nil, got %v", nil)
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
gucumber.T.Errorf("expect nil, got %v", nil)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func getAliasInformation(alias, region string) (string, error) {
|
||||
arn := ""
|
||||
svc := kms.New(session.New(&aws.Config{
|
||||
Region: ®ion,
|
||||
}))
|
||||
|
||||
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")
|
||||
}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
package s3manager
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
package s3
|
||||
+44
@@ -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)
|
||||
}
|
||||
+14
@@ -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
|
||||
|
||||
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+8
@@ -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
|
||||
|
||||
Generated
Vendored
+19
@@ -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")},
|
||||
)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+18
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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.
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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.
|
||||
"""
|
||||
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+12
@@ -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"
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+19
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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.
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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'
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+19
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+19
@@ -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"))
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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"
|
||||
|
||||
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+19
@@ -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
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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
|
||||
"""
|
||||
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
+18
@@ -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
|
||||
"""
|
||||
+19
@@ -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"))
|
||||
})
|
||||
}
|
||||
+14
@@ -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"
|
||||
+19
@@ -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"))
|
||||
})
|
||||
}
|
||||
+14
@@ -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"
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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.
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+16
@@ -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'.
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+18
@@ -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.
|
||||
"""
|
||||
Generated
Vendored
+16
@@ -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)
|
||||
})
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user