func TestInputService5ProtocolTestRecursiveShapesCase3(t *testing.T) { svc := NewInputService5ProtocolTest(nil) svc.Endpoint = "https://test" input := &InputService5TestShapeInputShape{ RecursiveStruct: &InputService5TestShapeRecursiveStructType{ RecursiveStruct: &InputService5TestShapeRecursiveStructType{ RecursiveStruct: &InputService5TestShapeRecursiveStructType{ RecursiveStruct: &InputService5TestShapeRecursiveStructType{ NoRecurse: aws.String("foo"), }, }, }, }, } req, _ := svc.InputService5TestCaseOperation3Request(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":{"RecursiveStruct":{"RecursiveStruct":{"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")) }
// Build builds a request for the REST JSON protocol. func Build(r *request.Request) { rest.Build(r) if t := rest.PayloadType(r.Params); t == "structure" || t == "" { jsonrpc.Build(r) } }
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 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 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 TestInputService3ProtocolTestBase64EncodedBlobsCase1(t *testing.T) { sess := session.New() svc := NewInputService3ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")}) input := &InputService3TestShapeInputShape{ BlobArg: []byte("foo"), } req, _ := svc.InputService3TestCaseOperation1Request(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, `{"BlobArg":"Zm9v"}`, 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 BenchmarkJSONRPCBuild_Simple_dynamodbPutItem(b *testing.B) { svc := service.New(nil) params := getDynamodbPutItemParams(b) for i := 0; i < b.N; i++ { r := svc.NewRequest(&request.Operation{Name: "Operation"}, params, nil) jsonrpc.Build(r) if r.Error != nil { b.Fatal("Unexpected error", r.Error) } } }
func TestInputService7ProtocolTestIdempotencyTokenAutoFillCase2(t *testing.T) { sess := session.New() svc := NewInputService7ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")}) input := &InputService7TestShapeInputShape{} req, _ := svc.InputService7TestCaseOperation2Request(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, `{"Token":"00000000-0000-4000-8000-000000000000"}`, util.Trim(string(body))) // assert URL awstesting.AssertURL(t, "https://test/path", r.URL.String()) // assert headers }