diff --git a/VERSION b/VERSION index 2b17ffd5042..2aeaa11ee27 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.34.0 +1.35.0 diff --git a/smithy-aws-protocol-tests/build.gradle b/smithy-aws-protocol-tests/build.gradle index a4110ceb9bd..176b63d58f4 100644 --- a/smithy-aws-protocol-tests/build.gradle +++ b/smithy-aws-protocol-tests/build.gradle @@ -27,6 +27,7 @@ ext { dependencies { implementation project(path: ":smithy-cli", configuration: "shadow") implementation project(":smithy-protocol-test-traits") + implementation project(":smithy-protocols-traits") implementation project(":smithy-aws-traits") api project(":smithy-validation-model") } diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy new file mode 100644 index 00000000000..26112138682 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -0,0 +1,142 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2 + +use aws.protocoltests.shared#StringList +use smithy.protocols#rpcv2 +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + + +@httpRequestTests([ + { + id: "RpcV2CborSimpleScalarProperties", + protocol: rpcv2, + documentation: "Serializes simple scalar properties", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=" + params: { + trueBooleanValue: true, + falseBooleanValue: false, + byteValue: 5, + doubleValue: 1.889, + floatValue: 7.624, + integerValue: 256, + shortValue: 9898, + longValue: 9873 + stringValue: "simple" + } + }, + { + id: "RpcV2CborClientDoesntSerializeNullStructureValues", + documentation: "RpcV2 Cbor should not serialize null structure values", + protocol: rpcv2, + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties", + body: "v/8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + params: { + stringValue: null + }, + appliesTo: "client" + }, + { + id: "RpcV2CborServerDoesntDeSerializeNullStructureValues", + documentation: "RpcV2 Cbor should not deserialize null structure values", + protocol: rpcv2, + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tzdHJpbmdWYWx1Zfb/", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + params: {}, + appliesTo: "server" + }, +]) +@httpResponseTests([ + { + id: "simple_scalar_structure", + protocol: rpcv2, + documentation: "Serializes simple scalar properties", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + bodyMediaType: "application/cbor", + body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=", + code: 200, + params: { + trueBooleanValue: true, + falseBooleanValue: false, + byteValue: 5, + doubleValue: 1.889, + floatValue: 7.624, + integerValue: 256, + shortValue: 9898, + stringValue: "simple" + } + }, + { + id: "RpcV2CborClientDoesntDeSerializeNullStructureValues", + documentation: "RpcV2 Cbor should deserialize null structure values", + protocol: rpcv2, + body: "v2tzdHJpbmdWYWx1Zfb/", + code: 200, + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + params: {} + appliesTo: "client" + }, + { + id: "RpcV2CborServerDoesntSerializeNullStructureValues", + documentation: "RpcV2 Cbor should not serialize null structure values", + protocol: rpcv2, + body: "v/8=", + code: 200, + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + params: { + stringValue: null + }, + appliesTo: "server" + }, +]) +operation SimpleScalarProperties { + input: SimpleScalarStructure, + output: SimpleScalarStructure +} + + +structure SimpleScalarStructure { + trueBooleanValue: Boolean, + falseBooleanValue: Boolean, + byteValue: Byte, + doubleValue: Double, + floatValue: Float, + integerValue: Integer, + longValue: Long, + shortValue: Short, + stringValue: String, +} \ No newline at end of file diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy new file mode 100644 index 00000000000..dfb67c65c88 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy @@ -0,0 +1,173 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2 + +use smithy.protocols#rpcv2 +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + + +@httpRequestTests([ + { + id: "no_input", + protocol: rpcv2, + documentation: "Body is empty and no Content-Type header if no input", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + }, + forbidHeaders: [ + "Content-Type", + "X-Amz-Target" + ] + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput", + body: "" + }, + { + id: "no_input_server_allows_accept", + protocol: rpcv2, + documentation: "Servers should allow the Accept header to be set to the default content-type.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput", + body: "", + appliesTo: "server" + }, + { + id: "no_input_server_allows_empty_cbor", + protocol: rpcv2, + documentation: "Servers should accept CBOR empty struct if no input.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput", + body: "v/8=", + appliesTo: "server" + } +]) +@httpResponseTests([ + { + id: "no_output", + protocol: rpcv2, + documentation: "Body is empty and no Content-Type header if no response", + body: "", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + }, + forbidHeaders: [ + "Content-Type" + ] + code: 200, + }, + { + id: "no_output_client_allows_accept", + protocol: rpcv2, + documentation: "Servers should allow the accept header to be set to the default content-type.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + body: "", + code: 200, + appliesTo: "client", + }, + { + id: "no_input_client_allows_empty_cbor", + protocol: rpcv2, + documentation: "Client should accept CBOR empty struct if no output", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + body: "v/8=", + code: 200, + appliesTo: "client", + } +]) +operation NoInputOutput {} + + +@httpRequestTests([ + { + id: "empty_input", + protocol: rpcv2, + documentation: "When Input structure is empty we write CBOR equivalent of {}", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + forbidHeaders: [ + "X-Amz-Target" + ] + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/EmptyInputOutput", + body: "v/8=", + }, +]) +@httpResponseTests([ + { + id: "empty_output", + protocol: rpcv2, + documentation: "When output structure is empty we write CBOR equivalent of {}", + body: "v/8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + code: 200, + }, +]) +operation EmptyInputOutput { + input: EmptyStructure, + output: EmptyStructure +} + +@httpRequestTests([ + { + id: "optional_input", + protocol: rpcv2, + documentation: "When input is empty we write CBOR equivalent of {}", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + forbidHeaders: [ + "X-Amz-Target" + ] + method: "POST", + uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/OptionalInputOutput", + body: "v/8=", + }, +]) +@httpResponseTests([ + { + id: "optional_output", + protocol: rpcv2, + documentation: "When output is empty we write CBOR equivalent of {}", + body: "v/8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + code: 200, + }, +]) +operation OptionalInputOutput { + input: SimpleStructure, + output: SimpleStructure +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-aws-protocol-tests/model/rpcV2/main.smithy new file mode 100644 index 00000000000..c827b1dd797 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/main.smithy @@ -0,0 +1,30 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2 +use aws.api#service +use smithy.protocols#rpcv2 +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + +@service(sdkId: "Sample RpcV2 Protocol") +@rpcv2(format: ["cbor"]) +@title("RpcV2 Protocol Service") +service RpcV2Protocol { + version: "2020-07-14", + operations: [ + //Basic input/output tests + NoInputOutput, + EmptyInputOutput, + OptionalInputOutput, + + SimpleScalarProperties, + ] +} + +structure EmptyStructure { + +} + +structure SimpleStructure { + value: String, +} \ No newline at end of file