vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2017-09-30 15:27:27 +01:00
parent 911d121bb9
commit b017fcfe9a
3048 changed files with 537055 additions and 189679 deletions
@@ -9,11 +9,10 @@ import (
"io/ioutil"
"net/http"
"os"
"reflect"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/integration"
"github.com/aws/aws-sdk-go/service/s3"
@@ -67,16 +66,22 @@ func TestWriteToObject(t *testing.T) {
Key: aws.String("key name"),
Body: bytes.NewReader([]byte("hello world")),
})
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
resp, err := svc.GetObject(&s3.GetObjectInput{
Bucket: bucketName,
Key: aws.String("key name"),
})
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
b, _ := ioutil.ReadAll(resp.Body)
assert.Equal(t, []byte("hello world"), b)
if e, a := []byte("hello world"), b; !reflect.DeepEqual(e, a) {
t.Errorf("expect %v, got %v", e, a)
}
}
func TestPresignedGetPut(t *testing.T) {
@@ -89,18 +94,26 @@ func TestPresignedGetPut(t *testing.T) {
// Presign a PUT request
var puturl string
puturl, err = putreq.Presign(300 * time.Second)
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
// PUT to the presigned URL with a body
var puthttpreq *http.Request
buf := bytes.NewReader([]byte("hello world"))
puthttpreq, err = http.NewRequest("PUT", puturl, buf)
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
var putresp *http.Response
putresp, err = http.DefaultClient.Do(puthttpreq)
assert.NoError(t, err)
assert.Equal(t, 200, putresp.StatusCode)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
if e, a := 200, putresp.StatusCode; e != a {
t.Errorf("expect %v, got %v", e, a)
}
// Presign a GET on the same URL
getreq, _ := svc.GetObjectRequest(&s3.GetObjectInput{
@@ -110,15 +123,21 @@ func TestPresignedGetPut(t *testing.T) {
var geturl string
geturl, err = getreq.Presign(300 * time.Second)
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
// Get the body
var getresp *http.Response
getresp, err = http.Get(geturl)
assert.NoError(t, err)
if err != nil {
t.Errorf("expect no error, got %v", err)
}
var b []byte
defer getresp.Body.Close()
b, err = ioutil.ReadAll(getresp.Body)
assert.Equal(t, "hello world", string(b))
if e, a := "hello world", string(b); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}
@@ -11,7 +11,6 @@ import (
"strings"
"github.com/gucumber/gucumber"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
@@ -31,7 +30,9 @@ func init() {
Bucket: aws.String(bucket),
Prefix: aws.String(baseFolder + "/" + prefix),
})
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
plaintexts := make(map[string][]byte)
for _, obj := range out.Contents {
@@ -40,10 +41,14 @@ func init() {
Bucket: aws.String(bucket),
Key: plaintextKey,
})
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
caseKey := strings.TrimPrefix(*plaintextKey, baseFolder+"/"+prefix)
plaintext, err := ioutil.ReadAll(ptObj.Body)
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
plaintexts[caseKey] = plaintext
}
@@ -84,10 +89,14 @@ func init() {
Key: &cipherKey,
},
)
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
ciphertext, err := ioutil.ReadAll(ctObj.Body)
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
ciphertexts[caseKey] = ciphertext
}
gucumber.World["decrypted"] = ciphertexts
@@ -97,8 +106,12 @@ func init() {
plaintexts := gucumber.World["plaintexts"].(map[string][]byte)
ciphertexts := gucumber.World["decrypted"].(map[string][]byte)
for caseKey, ciphertext := range ciphertexts {
assert.Equal(gucumber.T, len(plaintexts[caseKey]), len(ciphertext))
assert.True(gucumber.T, bytes.Equal(plaintexts[caseKey], ciphertext))
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)
}
}
})
@@ -108,16 +121,22 @@ func init() {
switch kek {
case "kms":
arn, err := getAliasInformation(v1, v2)
assert.Nil(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect nil, got %v", nil)
}
b64Arn := base64.StdEncoding.EncodeToString([]byte(arn))
assert.Nil(gucumber.T, err)
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)
assert.Nil(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect nil, got %v", nil)
}
default:
gucumber.T.Skip()
}
@@ -157,7 +176,9 @@ func init() {
}
_, err := c.PutObject(input)
assert.Nil(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect nil, got %v", nil)
}
}
})
}
+62 -24
View File
@@ -5,7 +5,6 @@ package smoke
import (
"encoding/json"
"fmt"
"os"
"reflect"
"regexp"
@@ -13,7 +12,6 @@ import (
"strings"
"github.com/gucumber/gucumber"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
@@ -47,12 +45,16 @@ func init() {
gucumber.Then(`^the value at "(.+?)" should be a list$`, func(member string) {
vals, _ := awsutil.ValuesAtPath(gucumber.World["response"], member)
assert.NotNil(gucumber.T, vals)
if vals == nil {
gucumber.T.Errorf("expect not nil, was")
}
})
gucumber.Then(`^the response should contain a "(.+?)"$`, func(member string) {
vals, _ := awsutil.ValuesAtPath(gucumber.World["response"], member)
assert.NotEmpty(gucumber.T, vals)
if len(vals) == 0 {
gucumber.T.Errorf("expect values, got none")
}
})
gucumber.When(`^I attempt to call the "(.+?)" API with:$`, func(op string, args [][]string) {
@@ -61,23 +63,33 @@ func init() {
gucumber.Then(`^I expect the response error code to be "(.+?)"$`, func(code string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if !ok {
gucumber.T.Errorf("no error returned")
}
if ok {
assert.Equal(gucumber.T, code, err.Code(), "Error: %v", err)
if e, a := code, err.Code(); e != a {
gucumber.T.Errorf("Error: %v", err)
}
}
})
gucumber.And(`^I expect the response error message to include:$`, func(data string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if !ok {
gucumber.T.Errorf("no error returned")
}
if ok {
assert.Contains(gucumber.T, err.Error(), data)
if e, a := data, err.Error(); !strings.Contains(a, e) {
gucumber.T.Errorf("expect %v to be in %v, was not", e, a)
}
}
})
gucumber.And(`^I expect the response error message to include one of:$`, func(table [][]string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
if !ok {
gucumber.T.Errorf("no error returned")
}
if ok {
found := false
for _, row := range table {
@@ -87,14 +99,20 @@ func init() {
}
}
assert.True(gucumber.T, found, fmt.Sprintf("no error messages matched: \"%s\"", err.Error()))
if !found {
gucumber.T.Errorf("no error messages matched: \"%s\"", err.Error())
}
}
})
gucumber.And(`^I expect the response error message not be empty$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.NotEmpty(gucumber.T, err.Message())
if !ok {
gucumber.T.Errorf("no error returned")
}
if len(err.Message()) == 0 {
gucumber.T.Errorf("expect values, got none")
}
})
gucumber.When(`^I call the "(.+?)" API with JSON:$`, func(s1 string, data string) {
@@ -107,26 +125,42 @@ func init() {
gucumber.Then(`^the error code should be "(.+?)"$`, func(s1 string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Equal(gucumber.T, s1, err.Code())
if !ok {
gucumber.T.Errorf("no error returned")
}
if e, a := s1, err.Code(); e != a {
gucumber.T.Errorf("expect %v, got %v", e, a)
}
})
gucumber.And(`^the error message should contain:$`, func(data string) {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Contains(gucumber.T, err.Error(), data)
if !ok {
gucumber.T.Errorf("no error returned")
}
if e, a := data, err.Error(); !strings.Contains(a, e) {
gucumber.T.Errorf("expect %v to be in %v, was not", e, a)
}
})
gucumber.Then(`^the request should fail$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.True(gucumber.T, ok, "no error returned")
assert.Error(gucumber.T, err)
if !ok {
gucumber.T.Errorf("no error returned")
}
if err == nil {
gucumber.T.Errorf("expect error, got none")
}
})
gucumber.Then(`^the request should be successful$`, func() {
err, ok := gucumber.World["error"].(awserr.Error)
assert.False(gucumber.T, ok, "error returned")
assert.NoError(gucumber.T, err)
if ok {
gucumber.T.Errorf("error returned")
}
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
})
}
@@ -160,10 +194,12 @@ func call(op string, args [][]string, allowError bool) {
if !allowError {
err, _ := gucumber.World["error"].(error)
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
}
} else {
assert.Fail(gucumber.T, "failed to find operation "+op)
gucumber.T.Errorf("failed to find operation " + op)
}
}
@@ -215,10 +251,12 @@ func callWithJSON(op, j string, allowError bool) {
if !allowError {
err, _ := gucumber.World["error"].(error)
assert.NoError(gucumber.T, err)
if err != nil {
gucumber.T.Errorf("expect no error, got %v", err)
}
}
} else {
assert.Fail(gucumber.T, "failed to find operation "+op)
gucumber.T.Errorf("failed to find operation " + op)
}
}