vendor: update all dependencies to latest versions
This commit is contained in:
Generated
Vendored
+31
-12
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+33
-12
@@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user