func TestInputService8ProtocolTestBase64EncodedBlobsCase1(t *testing.T) { svc := NewInputService8ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService8TestShapeInputService8TestCaseOperation1Input{ BlobArg: []byte("foo"), } req, _ := svc.InputService8TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&BlobArg=Zm9v&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService5ProtocolTestRecursiveShapesCase1(t *testing.T) { svc := NewInputService5ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService5TestShapeInputShape{ RecursiveStruct: &InputService5TestShapeRecursiveStructType{ NoRecurse: aws.String("foo"), }, } req, _ := svc.InputService5TestCaseOperation1Request(input) r := req.HTTPRequest // build request jsonrpc.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertJSON(t, `{"RecursiveStruct":{"NoRecurse":"foo"}}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type")) assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target")) }
func TestInputService4ProtocolTestNestedBlobsCase1(t *testing.T) { svc := NewInputService4ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService4TestShapeInputService4TestCaseOperation1Input{ ListParam: [][]byte{ []byte("foo"), []byte("bar"), }, } req, _ := svc.InputService4TestCaseOperation1Request(input) r := req.HTTPRequest // build request jsonrpc.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertJSON(t, `{"ListParam":["Zm9v","YmFy"]}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type")) assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target")) }
func TestInputService3ProtocolTestBase64EncodedBlobsCase2(t *testing.T) { svc := NewInputService3ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService3TestShapeInputShape{ BlobMap: map[string][]byte{ "key1": []byte("foo"), "key2": []byte("bar"), }, } req, _ := svc.InputService3TestCaseOperation2Request(input) r := req.HTTPRequest // build request jsonrpc.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertJSON(t, `{"BlobMap":{"key1":"Zm9v","key2":"YmFy"}}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type")) assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target")) }
func TestInputService2ProtocolTestTimestampValuesCase1(t *testing.T) { svc := NewInputService2ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService2TestShapeInputService2TestCaseOperation1Input{ TimeArg: aws.Time(time.Unix(1422172800, 0)), } req, _ := svc.InputService2TestCaseOperation1Request(input) r := req.HTTPRequest // build request jsonrpc.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertJSON(t, `{"TimeArg":1422172800}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type")) assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target")) }
func TestInputService6ProtocolTestEmptyMapsCase1(t *testing.T) { svc := NewInputService6ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService6TestShapeInputService6TestCaseOperation1Input{ Map: map[string]*string{}, } req, _ := svc.InputService6TestCaseOperation1Request(input) r := req.HTTPRequest // build request jsonrpc.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertJSON(t, `{"Map":{}}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type")) assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target")) }
func (t tplInputTestCaseData) BodyAssertions() string { code := &bytes.Buffer{} protocol := t.TestCase.TestSuite.API.Metadata.Protocol // Extract the body bytes switch protocol { case "rest-xml": fmt.Fprintln(code, "body := util.SortXML(r.Body)") default: fmt.Fprintln(code, "body, _ := ioutil.ReadAll(r.Body)") } // Generate the body verification code expectedBody := util.Trim(t.TestCase.InputTest.Body) switch protocol { case "ec2", "query": fmt.Fprintf(code, "awstesting.AssertQuery(t, `%s`, util.Trim(string(body)))", expectedBody) case "rest-xml": if strings.HasPrefix(expectedBody, "<") { fmt.Fprintf(code, "awstesting.AssertXML(t, `%s`, util.Trim(string(body)), %s{})", expectedBody, t.TestCase.Given.InputRef.ShapeName) } else { fmt.Fprintf(code, "assert.Equal(t, `%s`, util.Trim(string(body)))", expectedBody) } case "json", "jsonrpc", "rest-json": if strings.HasPrefix(expectedBody, "{") { fmt.Fprintf(code, "awstesting.AssertJSON(t, `%s`, util.Trim(string(body)))", expectedBody) } else { fmt.Fprintf(code, "assert.Equal(t, `%s`, util.Trim(string(body)))", expectedBody) } default: fmt.Fprintf(code, "assert.Equal(t, `%s`, util.Trim(string(body)))", expectedBody) } return code.String() }
func TestInputService1ProtocolTestScalarMembersCase1(t *testing.T) { svc := NewInputService1ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService1TestShapeInputService1TestCaseOperation1Input{ Bar: aws.String("val2"), Foo: aws.String("val1"), } req, _ := svc.InputService1TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&Bar=val2&Foo=val1&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService10ProtocolTestRecursiveShapesCase6(t *testing.T) { svc := NewInputService10ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService10TestShapeInputShape{ RecursiveStruct: &InputService10TestShapeRecursiveStructType{ RecursiveMap: map[string]*InputService10TestShapeRecursiveStructType{ "bar": { NoRecurse: aws.String("bar"), }, "foo": { NoRecurse: aws.String("foo"), }, }, }, } req, _ := svc.InputService10TestCaseOperation6Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&RecursiveStruct.RecursiveMap.entry.1.key=foo&RecursiveStruct.RecursiveMap.entry.1.value.NoRecurse=foo&RecursiveStruct.RecursiveMap.entry.2.key=bar&RecursiveStruct.RecursiveMap.entry.2.value.NoRecurse=bar&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService9ProtocolTestTimestampValuesCase1(t *testing.T) { svc := NewInputService9ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService9TestShapeInputService9TestCaseOperation1Input{ TimeArg: aws.Time(time.Unix(1422172800, 0)), } req, _ := svc.InputService9TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&TimeArg=2015-01-25T08%3A00%3A00Z&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService7ProtocolTestSerializeMapTypeWithLocationNameCase1(t *testing.T) { svc := NewInputService7ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService7TestShapeInputService7TestCaseOperation1Input{ MapArg: map[string]*string{ "key1": aws.String("val1"), "key2": aws.String("val2"), }, } req, _ := svc.InputService7TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&MapArg.entry.1.TheKey=key1&MapArg.entry.1.TheValue=val1&MapArg.entry.2.TheKey=key2&MapArg.entry.2.TheValue=val2&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService5ProtocolTestFlattenedListWithLocationNameCase1(t *testing.T) { svc := NewInputService5ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService5TestShapeInputService5TestCaseOperation1Input{ ListArg: []*string{ aws.String("a"), aws.String("b"), aws.String("c"), }, ScalarArg: aws.String("foo"), } req, _ := svc.InputService5TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&ListArgLocation.1=a&ListArgLocation.2=b&ListArgLocation.3=c&ScalarArg=foo&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService3ProtocolTestListTypesCase1(t *testing.T) { svc := NewInputService3ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService3TestShapeInputService3TestCaseOperation1Input{ ListArg: []*string{ aws.String("foo"), aws.String("bar"), aws.String("baz"), }, } req, _ := svc.InputService3TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&ListArg.member.1=foo&ListArg.member.2=bar&ListArg.member.3=baz&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
func TestInputService2ProtocolTestNestedStructureMembersCase1(t *testing.T) { svc := NewInputService2ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService2TestShapeInputService2TestCaseOperation1Input{ StructArg: &InputService2TestShapeStructType{ ScalarArg: aws.String("foo"), }, } req, _ := svc.InputService2TestCaseOperation1Request(input) r := req.HTTPRequest // build request query.Build(req) assert.NoError(t, req.Error) // assert body assert.NotNil(t, r.Body) body, _ := ioutil.ReadAll(r.Body) awstesting.AssertQuery(t, `Action=OperationName&StructArg.ScalarArg=foo&Version=2014-01-01`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/", r.URL.String()) // assert headers }
"github.com/upstartmobile/aws-sdk-go/awstesting" "github.com/upstartmobile/aws-sdk-go/private/protocol/query" "github.com/upstartmobile/aws-sdk-go/private/protocol/xml/xmlutil" "github.com/upstartmobile/aws-sdk-go/private/signer/v4" "github.com/upstartmobile/aws-sdk-go/private/util" ) var _ bytes.Buffer // always import bytes var _ http.Request var _ json.Marshaler var _ time.Time var _ xmlutil.XMLNode var _ xml.Attr var _ = awstesting.GenerateAssertions var _ = ioutil.Discard var _ = util.Trim("") var _ = url.Values{} var _ = io.EOF type InputService1ProtocolTest struct { *service.Service } // New returns a new InputService1ProtocolTest client. func NewInputService1ProtocolTest(config *aws.Config) *InputService1ProtocolTest { service := &service.Service{ ServiceInfo: serviceinfo.ServiceInfo{ Config: defaults.DefaultConfig.Merge(config), ServiceName: "inputservice1protocoltest", APIVersion: "2014-01-01", },