Skip to content

Commit

Permalink
Basic protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adwsingh committed Aug 9, 2023
1 parent cc3eda2 commit b4a0ff5
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.34.0
1.35.0
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
142 changes: 142 additions & 0 deletions smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy
Original file line number Diff line number Diff line change
@@ -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,
}
173 changes: 173 additions & 0 deletions smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 30 additions & 0 deletions smithy-aws-protocol-tests/model/rpcV2/main.smithy
Original file line number Diff line number Diff line change
@@ -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,
}

0 comments on commit b4a0ff5

Please sign in to comment.