Dep helper (#2151)
* Add dep task to update go dependencies * Update go dependencies
This commit is contained in:
parent
8f8b81f56b
commit
0e8977761d
764 changed files with 172 additions and 267451 deletions
106
vendor/github.com/aws/aws-sdk-go/private/protocol/idempotency_test.go
generated
vendored
106
vendor/github.com/aws/aws-sdk-go/private/protocol/idempotency_test.go
generated
vendored
|
@ -1,106 +0,0 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCanSetIdempotencyToken(t *testing.T) {
|
||||
cases := []struct {
|
||||
CanSet bool
|
||||
Case interface{}
|
||||
}{
|
||||
{
|
||||
true,
|
||||
struct {
|
||||
Field *string `idempotencyToken:"true"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
true,
|
||||
struct {
|
||||
Field string `idempotencyToken:"true"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
false,
|
||||
struct {
|
||||
Field *string `idempotencyToken:"true"`
|
||||
}{Field: new(string)},
|
||||
},
|
||||
{
|
||||
false,
|
||||
struct {
|
||||
Field string `idempotencyToken:"true"`
|
||||
}{Field: "value"},
|
||||
},
|
||||
{
|
||||
false,
|
||||
struct {
|
||||
Field *int `idempotencyToken:"true"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
false,
|
||||
struct {
|
||||
Field *string
|
||||
}{},
|
||||
},
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
v := reflect.Indirect(reflect.ValueOf(c.Case))
|
||||
ty := v.Type()
|
||||
canSet := protocol.CanSetIdempotencyToken(v.Field(0), ty.Field(0))
|
||||
assert.Equal(t, c.CanSet, canSet, "Expect case %d can set to match", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetIdempotencyToken(t *testing.T) {
|
||||
cases := []struct {
|
||||
Case interface{}
|
||||
}{
|
||||
{
|
||||
&struct {
|
||||
Field *string `idempotencyToken:"true"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
&struct {
|
||||
Field string `idempotencyToken:"true"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
&struct {
|
||||
Field *string `idempotencyToken:"true"`
|
||||
}{Field: new(string)},
|
||||
},
|
||||
{
|
||||
&struct {
|
||||
Field string `idempotencyToken:"true"`
|
||||
}{Field: ""},
|
||||
},
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
v := reflect.Indirect(reflect.ValueOf(c.Case))
|
||||
|
||||
protocol.SetIdempotencyToken(v.Field(0))
|
||||
assert.NotEmpty(t, v.Field(0).Interface(), "Expect case %d to be set", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUUIDVersion4(t *testing.T) {
|
||||
uuid := protocol.UUIDVersion4(make([]byte, 16))
|
||||
assert.Equal(t, `00000000-0000-4000-8000-000000000000`, uuid)
|
||||
|
||||
b := make([]byte, 16)
|
||||
for i := 0; i < len(b); i++ {
|
||||
b[i] = 1
|
||||
}
|
||||
uuid = protocol.UUIDVersion4(b)
|
||||
assert.Equal(t, `01010101-0101-4101-8101-010101010101`, uuid)
|
||||
}
|
93
vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue_test.go
generated
vendored
93
vendor/github.com/aws/aws-sdk-go/private/protocol/jsonvalue_test.go
generated
vendored
|
@ -1,93 +0,0 @@
|
|||
package protocol
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
)
|
||||
|
||||
var testJSONValueCases = []struct {
|
||||
Value aws.JSONValue
|
||||
Mode EscapeMode
|
||||
String string
|
||||
}{
|
||||
{
|
||||
Value: aws.JSONValue{
|
||||
"abc": 123.,
|
||||
},
|
||||
Mode: NoEscape,
|
||||
String: `{"abc":123}`,
|
||||
},
|
||||
{
|
||||
Value: aws.JSONValue{
|
||||
"abc": 123.,
|
||||
},
|
||||
Mode: Base64Escape,
|
||||
String: `eyJhYmMiOjEyM30=`,
|
||||
},
|
||||
{
|
||||
Value: aws.JSONValue{
|
||||
"abc": 123.,
|
||||
},
|
||||
Mode: QuotedEscape,
|
||||
String: `"{\"abc\":123}"`,
|
||||
},
|
||||
}
|
||||
|
||||
func TestEncodeJSONValue(t *testing.T) {
|
||||
for i, c := range testJSONValueCases {
|
||||
str, err := EncodeJSONValue(c.Value, c.Mode)
|
||||
if err != nil {
|
||||
t.Fatalf("%d, expect no error, got %v", i, err)
|
||||
}
|
||||
if e, a := c.String, str; e != a {
|
||||
t.Errorf("%d, expect %v encoded value, got %v", i, e, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeJSONValue(t *testing.T) {
|
||||
for i, c := range testJSONValueCases {
|
||||
val, err := DecodeJSONValue(c.String, c.Mode)
|
||||
if err != nil {
|
||||
t.Fatalf("%d, expect no error, got %v", i, err)
|
||||
}
|
||||
if e, a := c.Value, val; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d, expect %v encoded value, got %v", i, e, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEncodeJSONValue_PanicUnkownMode(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
t.Errorf("expect panic, got none")
|
||||
} else {
|
||||
reason := fmt.Sprintf("%v", r)
|
||||
if e, a := "unknown EscapeMode", reason; !strings.Contains(a, e) {
|
||||
t.Errorf("expect %q to be in %v", e, a)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
val := aws.JSONValue{}
|
||||
|
||||
EncodeJSONValue(val, 123456)
|
||||
}
|
||||
func TestDecodeJSONValue_PanicUnkownMode(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
t.Errorf("expect panic, got none")
|
||||
} else {
|
||||
reason := fmt.Sprintf("%v", r)
|
||||
if e, a := "unknown EscapeMode", reason; !strings.Contains(a, e) {
|
||||
t.Errorf("expect %q to be in %v", e, a)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
DecodeJSONValue(`{"abc":123}`, 123456)
|
||||
}
|
203
vendor/github.com/aws/aws-sdk-go/private/protocol/protocol_test.go
generated
vendored
203
vendor/github.com/aws/aws-sdk-go/private/protocol/protocol_test.go
generated
vendored
|
@ -1,203 +0,0 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/awstesting"
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/ec2query"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/query"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/rest"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restjson"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restxml"
|
||||
)
|
||||
|
||||
func xmlData(set bool, b []byte, size, delta int) {
|
||||
const openingTags = "<B><A>"
|
||||
const closingTags = "</A></B>"
|
||||
if !set {
|
||||
copy(b, []byte(openingTags))
|
||||
}
|
||||
if size == 0 {
|
||||
copy(b[delta-len(closingTags):], []byte(closingTags))
|
||||
}
|
||||
}
|
||||
|
||||
func jsonData(set bool, b []byte, size, delta int) {
|
||||
if !set {
|
||||
copy(b, []byte("{\"A\": \""))
|
||||
}
|
||||
if size == 0 {
|
||||
copy(b[delta-len("\"}"):], []byte("\"}"))
|
||||
}
|
||||
}
|
||||
|
||||
func buildNewRequest(data interface{}) *request.Request {
|
||||
v := url.Values{}
|
||||
v.Set("test", "TEST")
|
||||
v.Add("test1", "TEST1")
|
||||
|
||||
req := &request.Request{
|
||||
HTTPRequest: &http.Request{
|
||||
Header: make(http.Header),
|
||||
Body: &awstesting.ReadCloser{Size: 2048},
|
||||
URL: &url.URL{
|
||||
RawQuery: v.Encode(),
|
||||
},
|
||||
},
|
||||
Params: &struct {
|
||||
LocationName string `locationName:"test"`
|
||||
}{
|
||||
"Test",
|
||||
},
|
||||
ClientInfo: metadata.ClientInfo{
|
||||
ServiceName: "test",
|
||||
TargetPrefix: "test",
|
||||
JSONVersion: "test",
|
||||
APIVersion: "test",
|
||||
Endpoint: "test",
|
||||
SigningName: "test",
|
||||
SigningRegion: "test",
|
||||
},
|
||||
Operation: &request.Operation{
|
||||
Name: "test",
|
||||
},
|
||||
}
|
||||
req.HTTPResponse = &http.Response{
|
||||
Body: &awstesting.ReadCloser{Size: 2048},
|
||||
Header: http.Header{
|
||||
"X-Amzn-Requestid": []string{"1"},
|
||||
},
|
||||
StatusCode: http.StatusOK,
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
data = &struct {
|
||||
_ struct{} `type:"structure"`
|
||||
LocationName *string `locationName:"testName"`
|
||||
Location *string `location:"statusCode"`
|
||||
A *string `type:"string"`
|
||||
}{}
|
||||
}
|
||||
|
||||
req.Data = data
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
type expected struct {
|
||||
dataType int
|
||||
closed bool
|
||||
size int
|
||||
errExists bool
|
||||
}
|
||||
|
||||
const (
|
||||
jsonType = iota
|
||||
xmlType
|
||||
)
|
||||
|
||||
func checkForLeak(data interface{}, build, fn func(*request.Request), t *testing.T, result expected) {
|
||||
req := buildNewRequest(data)
|
||||
reader := req.HTTPResponse.Body.(*awstesting.ReadCloser)
|
||||
switch result.dataType {
|
||||
case jsonType:
|
||||
reader.FillData = jsonData
|
||||
case xmlType:
|
||||
reader.FillData = xmlData
|
||||
}
|
||||
build(req)
|
||||
fn(req)
|
||||
|
||||
if result.errExists {
|
||||
assert.NotNil(t, req.Error)
|
||||
} else {
|
||||
assert.Nil(t, req.Error)
|
||||
}
|
||||
|
||||
assert.Equal(t, reader.Closed, result.closed)
|
||||
assert.Equal(t, reader.Size, result.size)
|
||||
}
|
||||
|
||||
func TestJSONRpc(t *testing.T) {
|
||||
checkForLeak(nil, jsonrpc.Build, jsonrpc.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(nil, jsonrpc.Build, jsonrpc.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
checkForLeak(nil, jsonrpc.Build, jsonrpc.UnmarshalError, t, expected{jsonType, true, 0, true})
|
||||
}
|
||||
|
||||
func TestQuery(t *testing.T) {
|
||||
checkForLeak(nil, query.Build, query.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(nil, query.Build, query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
checkForLeak(nil, query.Build, query.UnmarshalError, t, expected{jsonType, true, 0, true})
|
||||
}
|
||||
|
||||
func TestRest(t *testing.T) {
|
||||
// case 1: Payload io.ReadSeeker
|
||||
checkForLeak(nil, rest.Build, rest.Unmarshal, t, expected{jsonType, false, 2048, false})
|
||||
checkForLeak(nil, query.Build, query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
|
||||
// case 2: Payload *string
|
||||
// should close the body
|
||||
dataStr := struct {
|
||||
_ struct{} `type:"structure" payload:"Payload"`
|
||||
LocationName *string `locationName:"testName"`
|
||||
Location *string `location:"statusCode"`
|
||||
A *string `type:"string"`
|
||||
Payload *string `locationName:"payload" type:"blob" required:"true"`
|
||||
}{}
|
||||
checkForLeak(&dataStr, rest.Build, rest.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(&dataStr, query.Build, query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
|
||||
// case 3: Payload []byte
|
||||
// should close the body
|
||||
dataBytes := struct {
|
||||
_ struct{} `type:"structure" payload:"Payload"`
|
||||
LocationName *string `locationName:"testName"`
|
||||
Location *string `location:"statusCode"`
|
||||
A *string `type:"string"`
|
||||
Payload []byte `locationName:"payload" type:"blob" required:"true"`
|
||||
}{}
|
||||
checkForLeak(&dataBytes, rest.Build, rest.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(&dataBytes, query.Build, query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
|
||||
// case 4: Payload unsupported type
|
||||
// should close the body
|
||||
dataUnsupported := struct {
|
||||
_ struct{} `type:"structure" payload:"Payload"`
|
||||
LocationName *string `locationName:"testName"`
|
||||
Location *string `location:"statusCode"`
|
||||
A *string `type:"string"`
|
||||
Payload string `locationName:"payload" type:"blob" required:"true"`
|
||||
}{}
|
||||
checkForLeak(&dataUnsupported, rest.Build, rest.Unmarshal, t, expected{jsonType, true, 0, true})
|
||||
checkForLeak(&dataUnsupported, query.Build, query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
}
|
||||
|
||||
func TestRestJSON(t *testing.T) {
|
||||
checkForLeak(nil, restjson.Build, restjson.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(nil, restjson.Build, restjson.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
checkForLeak(nil, restjson.Build, restjson.UnmarshalError, t, expected{jsonType, true, 0, true})
|
||||
}
|
||||
|
||||
func TestRestXML(t *testing.T) {
|
||||
checkForLeak(nil, restxml.Build, restxml.Unmarshal, t, expected{xmlType, true, 0, false})
|
||||
checkForLeak(nil, restxml.Build, restxml.UnmarshalMeta, t, expected{xmlType, false, 2048, false})
|
||||
checkForLeak(nil, restxml.Build, restxml.UnmarshalError, t, expected{xmlType, true, 0, true})
|
||||
}
|
||||
|
||||
func TestXML(t *testing.T) {
|
||||
checkForLeak(nil, ec2query.Build, ec2query.Unmarshal, t, expected{jsonType, true, 0, false})
|
||||
checkForLeak(nil, ec2query.Build, ec2query.UnmarshalMeta, t, expected{jsonType, false, 2048, false})
|
||||
checkForLeak(nil, ec2query.Build, ec2query.UnmarshalError, t, expected{jsonType, true, 0, true})
|
||||
}
|
||||
|
||||
func TestProtocol(t *testing.T) {
|
||||
checkForLeak(nil, restxml.Build, protocol.UnmarshalDiscardBody, t, expected{xmlType, true, 0, false})
|
||||
}
|
4071
vendor/github.com/aws/aws-sdk-go/private/protocol/query/build_test.go
generated
vendored
4071
vendor/github.com/aws/aws-sdk-go/private/protocol/query/build_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
3007
vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_test.go
generated
vendored
3007
vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build_test.go
generated
vendored
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build_test.go
generated
vendored
|
@ -1,63 +0,0 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
func TestCleanPath(t *testing.T) {
|
||||
uri := &url.URL{
|
||||
Path: "//foo//bar",
|
||||
Scheme: "https",
|
||||
Host: "host",
|
||||
}
|
||||
cleanPath(uri)
|
||||
|
||||
expected := "https://host/foo/bar"
|
||||
if a, e := uri.String(), expected; a != e {
|
||||
t.Errorf("expect %q URI, got %q", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalPath(t *testing.T) {
|
||||
in := struct {
|
||||
Bucket *string `location:"uri" locationName:"bucket"`
|
||||
Key *string `location:"uri" locationName:"key"`
|
||||
}{
|
||||
Bucket: aws.String("mybucket"),
|
||||
Key: aws.String("my/cool+thing space/object世界"),
|
||||
}
|
||||
|
||||
expectURL := `/mybucket/my/cool+thing space/object世界`
|
||||
expectEscapedURL := `/mybucket/my/cool%2Bthing%20space/object%E4%B8%96%E7%95%8C`
|
||||
|
||||
req := &request.Request{
|
||||
HTTPRequest: &http.Request{
|
||||
URL: &url.URL{Scheme: "https", Host: "exmaple.com", Path: "/{bucket}/{key+}"},
|
||||
},
|
||||
Params: &in,
|
||||
}
|
||||
|
||||
Build(req)
|
||||
|
||||
if req.Error != nil {
|
||||
t.Fatalf("unexpected error, %v", req.Error)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.Path, expectURL; a != e {
|
||||
t.Errorf("expect %q URI, got %q", e, a)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.RawPath, expectEscapedURL; a != e {
|
||||
t.Errorf("expect %q escaped URI, got %q", e, a)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.EscapedPath(), expectEscapedURL; a != e {
|
||||
t.Errorf("expect %q escaped URI, got %q", e, a)
|
||||
}
|
||||
|
||||
}
|
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/rest_test.go
generated
vendored
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/rest_test.go
generated
vendored
|
@ -1,63 +0,0 @@
|
|||
package rest_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"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/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/rest"
|
||||
)
|
||||
|
||||
func TestUnsetHeaders(t *testing.T) {
|
||||
cfg := &aws.Config{Region: aws.String("us-west-2")}
|
||||
c := unit.Session.ClientConfig("testService", cfg)
|
||||
svc := client.New(
|
||||
*cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: "testService",
|
||||
SigningName: c.SigningName,
|
||||
SigningRegion: c.SigningRegion,
|
||||
Endpoint: c.Endpoint,
|
||||
APIVersion: "",
|
||||
},
|
||||
c.Handlers,
|
||||
)
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(rest.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(rest.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(rest.UnmarshalMetaHandler)
|
||||
op := &request.Operation{
|
||||
Name: "test-operation",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
input := &struct {
|
||||
Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"`
|
||||
Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"`
|
||||
}{}
|
||||
|
||||
output := &struct {
|
||||
Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"`
|
||||
Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"`
|
||||
}{}
|
||||
|
||||
req := svc.NewRequest(op, input, output)
|
||||
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewBuffer(nil)), Header: http.Header{}}
|
||||
req.HTTPResponse.Header.Set("X-Amz-Foo", "e30=")
|
||||
|
||||
// unmarshal response
|
||||
rest.UnmarshalMeta(req)
|
||||
rest.Unmarshal(req)
|
||||
if req.Error != nil {
|
||||
t.Fatal(req.Error)
|
||||
}
|
||||
}
|
366
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/build_bench_test.go
generated
vendored
366
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/build_bench_test.go
generated
vendored
|
@ -1,366 +0,0 @@
|
|||
// +build bench
|
||||
|
||||
package restxml_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/endpoints"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restxml"
|
||||
"github.com/aws/aws-sdk-go/service/cloudfront"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
var (
|
||||
cloudfrontSvc *cloudfront.CloudFront
|
||||
s3Svc *s3.S3
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
|
||||
sess := session.Must(session.NewSession(&aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials("Key", "Secret", "Token"),
|
||||
Endpoint: aws.String(server.URL),
|
||||
S3ForcePathStyle: aws.Bool(true),
|
||||
DisableSSL: aws.Bool(true),
|
||||
Region: aws.String(endpoints.UsWest2RegionID),
|
||||
}))
|
||||
cloudfrontSvc = cloudfront.New(sess)
|
||||
s3Svc = s3.New(sess)
|
||||
|
||||
c := m.Run()
|
||||
server.Close()
|
||||
os.Exit(c)
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLBuild_Complex_CFCreateDistro(b *testing.B) {
|
||||
params := cloudfrontCreateDistributionInput()
|
||||
|
||||
benchRESTXMLBuild(b, func() *request.Request {
|
||||
req, _ := cloudfrontSvc.CreateDistributionRequest(params)
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLBuild_Simple_CFDeleteDistro(b *testing.B) {
|
||||
params := cloudfrontDeleteDistributionInput()
|
||||
|
||||
benchRESTXMLBuild(b, func() *request.Request {
|
||||
req, _ := cloudfrontSvc.DeleteDistributionRequest(params)
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLBuild_REST_S3HeadObject(b *testing.B) {
|
||||
params := s3HeadObjectInput()
|
||||
|
||||
benchRESTXMLBuild(b, func() *request.Request {
|
||||
req, _ := s3Svc.HeadObjectRequest(params)
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLBuild_XML_S3PutObjectAcl(b *testing.B) {
|
||||
params := s3PutObjectAclInput()
|
||||
|
||||
benchRESTXMLBuild(b, func() *request.Request {
|
||||
req, _ := s3Svc.PutObjectAclRequest(params)
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLRequest_Complex_CFCreateDistro(b *testing.B) {
|
||||
benchRESTXMLRequest(b, func() *request.Request {
|
||||
req, _ := cloudfrontSvc.CreateDistributionRequest(cloudfrontCreateDistributionInput())
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLRequest_Simple_CFDeleteDistro(b *testing.B) {
|
||||
benchRESTXMLRequest(b, func() *request.Request {
|
||||
req, _ := cloudfrontSvc.DeleteDistributionRequest(cloudfrontDeleteDistributionInput())
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLRequest_REST_S3HeadObject(b *testing.B) {
|
||||
benchRESTXMLRequest(b, func() *request.Request {
|
||||
req, _ := s3Svc.HeadObjectRequest(s3HeadObjectInput())
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkRESTXMLRequest_XML_S3PutObjectAcl(b *testing.B) {
|
||||
benchRESTXMLRequest(b, func() *request.Request {
|
||||
req, _ := s3Svc.PutObjectAclRequest(s3PutObjectAclInput())
|
||||
return req
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkEncodingXML_Simple(b *testing.B) {
|
||||
params := cloudfrontDeleteDistributionInput()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := &bytes.Buffer{}
|
||||
encoder := xml.NewEncoder(buf)
|
||||
if err := encoder.Encode(params); err != nil {
|
||||
b.Fatal("Unexpected error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func benchRESTXMLBuild(b *testing.B, reqFn func() *request.Request) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
req := reqFn()
|
||||
restxml.Build(req)
|
||||
if req.Error != nil {
|
||||
b.Fatal("Unexpected error", req.Error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func benchRESTXMLRequest(b *testing.B, reqFn func() *request.Request) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
err := reqFn().Send()
|
||||
if err != nil {
|
||||
b.Fatal("Unexpected error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput {
|
||||
return &cloudfront.CreateDistributionInput{
|
||||
DistributionConfig: &cloudfront.DistributionConfig{ // Required
|
||||
CallerReference: aws.String("string"), // Required
|
||||
Comment: aws.String("string"), // Required
|
||||
DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required
|
||||
ForwardedValues: &cloudfront.ForwardedValues{ // Required
|
||||
Cookies: &cloudfront.CookiePreference{ // Required
|
||||
Forward: aws.String("ItemSelection"), // Required
|
||||
WhitelistedNames: &cloudfront.CookieNames{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
},
|
||||
QueryString: aws.Bool(true), // Required
|
||||
Headers: &cloudfront.Headers{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
},
|
||||
MinTTL: aws.Int64(1), // Required
|
||||
TargetOriginId: aws.String("string"), // Required
|
||||
TrustedSigners: &cloudfront.TrustedSigners{ // Required
|
||||
Enabled: aws.Bool(true), // Required
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required
|
||||
AllowedMethods: &cloudfront.AllowedMethods{
|
||||
Items: []*string{ // Required
|
||||
aws.String("Method"), // Required
|
||||
// More values...
|
||||
},
|
||||
Quantity: aws.Int64(1), // Required
|
||||
CachedMethods: &cloudfront.CachedMethods{
|
||||
Items: []*string{ // Required
|
||||
aws.String("Method"), // Required
|
||||
// More values...
|
||||
},
|
||||
Quantity: aws.Int64(1), // Required
|
||||
},
|
||||
},
|
||||
DefaultTTL: aws.Int64(1),
|
||||
MaxTTL: aws.Int64(1),
|
||||
SmoothStreaming: aws.Bool(true),
|
||||
},
|
||||
Enabled: aws.Bool(true), // Required
|
||||
Origins: &cloudfront.Origins{ // Required
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*cloudfront.Origin{
|
||||
{ // Required
|
||||
DomainName: aws.String("string"), // Required
|
||||
Id: aws.String("string"), // Required
|
||||
CustomOriginConfig: &cloudfront.CustomOriginConfig{
|
||||
HTTPPort: aws.Int64(1), // Required
|
||||
HTTPSPort: aws.Int64(1), // Required
|
||||
OriginProtocolPolicy: aws.String("OriginProtocolPolicy"), // Required
|
||||
},
|
||||
OriginPath: aws.String("string"),
|
||||
S3OriginConfig: &cloudfront.S3OriginConfig{
|
||||
OriginAccessIdentity: aws.String("string"), // Required
|
||||
},
|
||||
},
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
Aliases: &cloudfront.Aliases{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
CacheBehaviors: &cloudfront.CacheBehaviors{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*cloudfront.CacheBehavior{
|
||||
{ // Required
|
||||
ForwardedValues: &cloudfront.ForwardedValues{ // Required
|
||||
Cookies: &cloudfront.CookiePreference{ // Required
|
||||
Forward: aws.String("ItemSelection"), // Required
|
||||
WhitelistedNames: &cloudfront.CookieNames{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
},
|
||||
QueryString: aws.Bool(true), // Required
|
||||
Headers: &cloudfront.Headers{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
},
|
||||
MinTTL: aws.Int64(1), // Required
|
||||
PathPattern: aws.String("string"), // Required
|
||||
TargetOriginId: aws.String("string"), // Required
|
||||
TrustedSigners: &cloudfront.TrustedSigners{ // Required
|
||||
Enabled: aws.Bool(true), // Required
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required
|
||||
AllowedMethods: &cloudfront.AllowedMethods{
|
||||
Items: []*string{ // Required
|
||||
aws.String("Method"), // Required
|
||||
// More values...
|
||||
},
|
||||
Quantity: aws.Int64(1), // Required
|
||||
CachedMethods: &cloudfront.CachedMethods{
|
||||
Items: []*string{ // Required
|
||||
aws.String("Method"), // Required
|
||||
// More values...
|
||||
},
|
||||
Quantity: aws.Int64(1), // Required
|
||||
},
|
||||
},
|
||||
DefaultTTL: aws.Int64(1),
|
||||
MaxTTL: aws.Int64(1),
|
||||
SmoothStreaming: aws.Bool(true),
|
||||
},
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
CustomErrorResponses: &cloudfront.CustomErrorResponses{
|
||||
Quantity: aws.Int64(1), // Required
|
||||
Items: []*cloudfront.CustomErrorResponse{
|
||||
{ // Required
|
||||
ErrorCode: aws.Int64(1), // Required
|
||||
ErrorCachingMinTTL: aws.Int64(1),
|
||||
ResponseCode: aws.String("string"),
|
||||
ResponsePagePath: aws.String("string"),
|
||||
},
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
DefaultRootObject: aws.String("string"),
|
||||
Logging: &cloudfront.LoggingConfig{
|
||||
Bucket: aws.String("string"), // Required
|
||||
Enabled: aws.Bool(true), // Required
|
||||
IncludeCookies: aws.Bool(true), // Required
|
||||
Prefix: aws.String("string"), // Required
|
||||
},
|
||||
PriceClass: aws.String("PriceClass"),
|
||||
Restrictions: &cloudfront.Restrictions{
|
||||
GeoRestriction: &cloudfront.GeoRestriction{ // Required
|
||||
Quantity: aws.Int64(1), // Required
|
||||
RestrictionType: aws.String("GeoRestrictionType"), // Required
|
||||
Items: []*string{
|
||||
aws.String("string"), // Required
|
||||
// More values...
|
||||
},
|
||||
},
|
||||
},
|
||||
ViewerCertificate: &cloudfront.ViewerCertificate{
|
||||
CloudFrontDefaultCertificate: aws.Bool(true),
|
||||
IAMCertificateId: aws.String("string"),
|
||||
MinimumProtocolVersion: aws.String("MinimumProtocolVersion"),
|
||||
SSLSupportMethod: aws.String("SSLSupportMethod"),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func cloudfrontDeleteDistributionInput() *cloudfront.DeleteDistributionInput {
|
||||
return &cloudfront.DeleteDistributionInput{
|
||||
Id: aws.String("string"), // Required
|
||||
IfMatch: aws.String("string"),
|
||||
}
|
||||
}
|
||||
|
||||
func s3HeadObjectInput() *s3.HeadObjectInput {
|
||||
return &s3.HeadObjectInput{
|
||||
Bucket: aws.String("somebucketname"),
|
||||
Key: aws.String("keyname"),
|
||||
VersionId: aws.String("someVersion"),
|
||||
IfMatch: aws.String("IfMatch"),
|
||||
}
|
||||
}
|
||||
|
||||
func s3PutObjectAclInput() *s3.PutObjectAclInput {
|
||||
return &s3.PutObjectAclInput{
|
||||
Bucket: aws.String("somebucketname"),
|
||||
Key: aws.String("keyname"),
|
||||
AccessControlPolicy: &s3.AccessControlPolicy{
|
||||
Grants: []*s3.Grant{
|
||||
{
|
||||
Grantee: &s3.Grantee{
|
||||
DisplayName: aws.String("someName"),
|
||||
EmailAddress: aws.String("someAddr"),
|
||||
ID: aws.String("someID"),
|
||||
Type: aws.String(s3.TypeCanonicalUser),
|
||||
URI: aws.String("someURI"),
|
||||
},
|
||||
Permission: aws.String(s3.PermissionWrite),
|
||||
},
|
||||
},
|
||||
Owner: &s3.Owner{
|
||||
DisplayName: aws.String("howdy"),
|
||||
ID: aws.String("someID"),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
6369
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/build_test.go
generated
vendored
6369
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/build_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
3145
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/unmarshal_test.go
generated
vendored
3145
vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/unmarshal_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
40
vendor/github.com/aws/aws-sdk-go/private/protocol/unmarshal_test.go
generated
vendored
40
vendor/github.com/aws/aws-sdk-go/private/protocol/unmarshal_test.go
generated
vendored
|
@ -1,40 +0,0 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/protocol"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type mockCloser struct {
|
||||
*strings.Reader
|
||||
Closed bool
|
||||
}
|
||||
|
||||
func (m *mockCloser) Close() error {
|
||||
m.Closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestUnmarshalDrainBody(t *testing.T) {
|
||||
b := &mockCloser{Reader: strings.NewReader("example body")}
|
||||
r := &request.Request{HTTPResponse: &http.Response{
|
||||
Body: b,
|
||||
}}
|
||||
|
||||
protocol.UnmarshalDiscardBody(r)
|
||||
assert.NoError(t, r.Error)
|
||||
assert.Equal(t, 0, b.Len())
|
||||
assert.True(t, b.Closed)
|
||||
}
|
||||
|
||||
func TestUnmarshalDrainBodyNoBody(t *testing.T) {
|
||||
r := &request.Request{HTTPResponse: &http.Response{}}
|
||||
|
||||
protocol.UnmarshalDiscardBody(r)
|
||||
assert.NoError(t, r.Error)
|
||||
}
|
142
vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal_test.go
generated
vendored
142
vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal_test.go
generated
vendored
|
@ -1,142 +0,0 @@
|
|||
package xmlutil
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awsutil"
|
||||
)
|
||||
|
||||
type mockBody struct {
|
||||
DoneErr error
|
||||
Body io.Reader
|
||||
}
|
||||
|
||||
func (m *mockBody) Read(p []byte) (int, error) {
|
||||
n, err := m.Body.Read(p)
|
||||
if (n == 0 || err == io.EOF) && m.DoneErr != nil {
|
||||
return n, m.DoneErr
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
type mockOutput struct {
|
||||
_ struct{} `type:"structure"`
|
||||
String *string `type:"string"`
|
||||
Integer *int64 `type:"integer"`
|
||||
Nested *mockNestedStruct `type:"structure"`
|
||||
List []*mockListElem `locationName:"List" locationNameList:"Elem" type:"list"`
|
||||
Closed *mockClosedTags `type:"structure"`
|
||||
}
|
||||
type mockNestedStruct struct {
|
||||
_ struct{} `type:"structure"`
|
||||
NestedString *string `type:"string"`
|
||||
NestedInt *int64 `type:"integer"`
|
||||
}
|
||||
type mockClosedTags struct {
|
||||
_ struct{} `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"`
|
||||
Attr *string `locationName:"xsi:attrval" type:"string" xmlAttribute:"true"`
|
||||
}
|
||||
type mockListElem struct {
|
||||
_ struct{} `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"`
|
||||
String *string `type:"string"`
|
||||
NestedElem *mockNestedListElem `type:"structure"`
|
||||
}
|
||||
type mockNestedListElem struct {
|
||||
_ struct{} `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"`
|
||||
|
||||
String *string `type:"string"`
|
||||
Type *string `locationName:"xsi:type" type:"string" xmlAttribute:"true"`
|
||||
}
|
||||
|
||||
func TestUnmarshal(t *testing.T) {
|
||||
const xmlBodyStr = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MockResponse xmlns="http://xmlns.example.com">
|
||||
<String>string value</String>
|
||||
<Integer>123</Integer>
|
||||
<Closed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:attrval="attr value"/>
|
||||
<Nested>
|
||||
<NestedString>nested string value</NestedString>
|
||||
<NestedInt>321</NestedInt>
|
||||
</Nested>
|
||||
<List>
|
||||
<Elem>
|
||||
<NestedElem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="type">
|
||||
<String>nested elem string value</String>
|
||||
</NestedElem>
|
||||
<String>elem string value</String>
|
||||
</Elem>
|
||||
</List>
|
||||
</MockResponse>`
|
||||
|
||||
expect := mockOutput{
|
||||
String: aws.String("string value"),
|
||||
Integer: aws.Int64(123),
|
||||
Closed: &mockClosedTags{
|
||||
Attr: aws.String("attr value"),
|
||||
},
|
||||
Nested: &mockNestedStruct{
|
||||
NestedString: aws.String("nested string value"),
|
||||
NestedInt: aws.Int64(321),
|
||||
},
|
||||
List: []*mockListElem{
|
||||
{
|
||||
String: aws.String("elem string value"),
|
||||
NestedElem: &mockNestedListElem{
|
||||
String: aws.String("nested elem string value"),
|
||||
Type: aws.String("type"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual := mockOutput{}
|
||||
decoder := xml.NewDecoder(strings.NewReader(xmlBodyStr))
|
||||
err := UnmarshalXML(&actual, decoder, "")
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expect, actual) {
|
||||
t.Errorf("expect unmarshal to match\nExpect: %s\nActual: %s",
|
||||
awsutil.Prettify(expect), awsutil.Prettify(actual))
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshal_UnexpectedEOF(t *testing.T) {
|
||||
const partialXMLBody = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<First>first value</First>
|
||||
<Second>Second val`
|
||||
|
||||
out := struct {
|
||||
First *string `locationName:"First" type:"string"`
|
||||
Second *string `locationName:"Second" type:"string"`
|
||||
}{}
|
||||
|
||||
expect := out
|
||||
expect.First = aws.String("first")
|
||||
expect.Second = aws.String("second")
|
||||
|
||||
expectErr := fmt.Errorf("expected read error")
|
||||
|
||||
body := &mockBody{
|
||||
DoneErr: expectErr,
|
||||
Body: strings.NewReader(partialXMLBody),
|
||||
}
|
||||
|
||||
decoder := xml.NewDecoder(body)
|
||||
err := UnmarshalXML(&out, decoder, "")
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("expect error, got none")
|
||||
}
|
||||
if e, a := expectErr, err; e != a {
|
||||
t.Errorf("expect %v error in %v, but was not", e, a)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue