Skip to content

Commit b4a0ff5

Browse files
committed
Basic protocol tests
1 parent cc3eda2 commit b4a0ff5

File tree

5 files changed

+347
-1
lines changed

5 files changed

+347
-1
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.34.0
1+
1.35.0

smithy-aws-protocol-tests/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ext {
2727
dependencies {
2828
implementation project(path: ":smithy-cli", configuration: "shadow")
2929
implementation project(":smithy-protocol-test-traits")
30+
implementation project(":smithy-protocols-traits")
3031
implementation project(":smithy-aws-traits")
3132
api project(":smithy-validation-model")
3233
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
$version: "2.0"
2+
3+
namespace aws.protocoltests.rpcv2
4+
5+
use aws.protocoltests.shared#StringList
6+
use smithy.protocols#rpcv2
7+
use smithy.test#httpRequestTests
8+
use smithy.test#httpResponseTests
9+
10+
11+
@httpRequestTests([
12+
{
13+
id: "RpcV2CborSimpleScalarProperties",
14+
protocol: rpcv2,
15+
documentation: "Serializes simple scalar properties",
16+
headers: {
17+
"smithy-protocol": "rpc-v2-cbor",
18+
"Accept": "application/cbor",
19+
"Content-Type": "application/cbor"
20+
}
21+
method: "POST",
22+
bodyMediaType: "application/cbor",
23+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties",
24+
body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8="
25+
params: {
26+
trueBooleanValue: true,
27+
falseBooleanValue: false,
28+
byteValue: 5,
29+
doubleValue: 1.889,
30+
floatValue: 7.624,
31+
integerValue: 256,
32+
shortValue: 9898,
33+
longValue: 9873
34+
stringValue: "simple"
35+
}
36+
},
37+
{
38+
id: "RpcV2CborClientDoesntSerializeNullStructureValues",
39+
documentation: "RpcV2 Cbor should not serialize null structure values",
40+
protocol: rpcv2,
41+
method: "POST",
42+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties",
43+
body: "v/8=",
44+
bodyMediaType: "application/cbor",
45+
headers: {
46+
"smithy-protocol": "rpc-v2-cbor",
47+
"Accept": "application/cbor",
48+
"Content-Type": "application/cbor"
49+
}
50+
params: {
51+
stringValue: null
52+
},
53+
appliesTo: "client"
54+
},
55+
{
56+
id: "RpcV2CborServerDoesntDeSerializeNullStructureValues",
57+
documentation: "RpcV2 Cbor should not deserialize null structure values",
58+
protocol: rpcv2,
59+
method: "POST",
60+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties",
61+
body: "v2tzdHJpbmdWYWx1Zfb/",
62+
bodyMediaType: "application/cbor",
63+
headers: {
64+
"smithy-protocol": "rpc-v2-cbor",
65+
"Accept": "application/cbor",
66+
"Content-Type": "application/cbor"
67+
}
68+
params: {},
69+
appliesTo: "server"
70+
},
71+
])
72+
@httpResponseTests([
73+
{
74+
id: "simple_scalar_structure",
75+
protocol: rpcv2,
76+
documentation: "Serializes simple scalar properties",
77+
headers: {
78+
"smithy-protocol": "rpc-v2-cbor",
79+
"Content-Type": "application/cbor"
80+
}
81+
bodyMediaType: "application/cbor",
82+
body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=",
83+
code: 200,
84+
params: {
85+
trueBooleanValue: true,
86+
falseBooleanValue: false,
87+
byteValue: 5,
88+
doubleValue: 1.889,
89+
floatValue: 7.624,
90+
integerValue: 256,
91+
shortValue: 9898,
92+
stringValue: "simple"
93+
}
94+
},
95+
{
96+
id: "RpcV2CborClientDoesntDeSerializeNullStructureValues",
97+
documentation: "RpcV2 Cbor should deserialize null structure values",
98+
protocol: rpcv2,
99+
body: "v2tzdHJpbmdWYWx1Zfb/",
100+
code: 200,
101+
bodyMediaType: "application/cbor",
102+
headers: {
103+
"smithy-protocol": "rpc-v2-cbor",
104+
"Content-Type": "application/cbor"
105+
}
106+
params: {}
107+
appliesTo: "client"
108+
},
109+
{
110+
id: "RpcV2CborServerDoesntSerializeNullStructureValues",
111+
documentation: "RpcV2 Cbor should not serialize null structure values",
112+
protocol: rpcv2,
113+
body: "v/8=",
114+
code: 200,
115+
bodyMediaType: "application/cbor",
116+
headers: {
117+
"smithy-protocol": "rpc-v2-cbor",
118+
"Content-Type": "application/cbor"
119+
}
120+
params: {
121+
stringValue: null
122+
},
123+
appliesTo: "server"
124+
},
125+
])
126+
operation SimpleScalarProperties {
127+
input: SimpleScalarStructure,
128+
output: SimpleScalarStructure
129+
}
130+
131+
132+
structure SimpleScalarStructure {
133+
trueBooleanValue: Boolean,
134+
falseBooleanValue: Boolean,
135+
byteValue: Byte,
136+
doubleValue: Double,
137+
floatValue: Float,
138+
integerValue: Integer,
139+
longValue: Long,
140+
shortValue: Short,
141+
stringValue: String,
142+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
$version: "2.0"
2+
3+
namespace aws.protocoltests.rpcv2
4+
5+
use smithy.protocols#rpcv2
6+
use smithy.test#httpRequestTests
7+
use smithy.test#httpResponseTests
8+
9+
10+
@httpRequestTests([
11+
{
12+
id: "no_input",
13+
protocol: rpcv2,
14+
documentation: "Body is empty and no Content-Type header if no input",
15+
headers: {
16+
"smithy-protocol": "rpc-v2-cbor",
17+
"Accept": "application/cbor",
18+
},
19+
forbidHeaders: [
20+
"Content-Type",
21+
"X-Amz-Target"
22+
]
23+
method: "POST",
24+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput",
25+
body: ""
26+
},
27+
{
28+
id: "no_input_server_allows_accept",
29+
protocol: rpcv2,
30+
documentation: "Servers should allow the Accept header to be set to the default content-type.",
31+
headers: {
32+
"smithy-protocol": "rpc-v2-cbor",
33+
"Accept": "application/cbor",
34+
"Content-Type": "application/cbor"
35+
}
36+
method: "POST",
37+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput",
38+
body: "",
39+
appliesTo: "server"
40+
},
41+
{
42+
id: "no_input_server_allows_empty_cbor",
43+
protocol: rpcv2,
44+
documentation: "Servers should accept CBOR empty struct if no input.",
45+
headers: {
46+
"smithy-protocol": "rpc-v2-cbor",
47+
"Accept": "application/cbor",
48+
"Content-Type": "application/cbor"
49+
}
50+
method: "POST",
51+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/NoInputOutput",
52+
body: "v/8=",
53+
appliesTo: "server"
54+
}
55+
])
56+
@httpResponseTests([
57+
{
58+
id: "no_output",
59+
protocol: rpcv2,
60+
documentation: "Body is empty and no Content-Type header if no response",
61+
body: "",
62+
bodyMediaType: "application/cbor",
63+
headers: {
64+
"smithy-protocol": "rpc-v2-cbor",
65+
},
66+
forbidHeaders: [
67+
"Content-Type"
68+
]
69+
code: 200,
70+
},
71+
{
72+
id: "no_output_client_allows_accept",
73+
protocol: rpcv2,
74+
documentation: "Servers should allow the accept header to be set to the default content-type.",
75+
headers: {
76+
"smithy-protocol": "rpc-v2-cbor",
77+
"Accept": "application/cbor",
78+
"Content-Type": "application/cbor"
79+
}
80+
body: "",
81+
code: 200,
82+
appliesTo: "client",
83+
},
84+
{
85+
id: "no_input_client_allows_empty_cbor",
86+
protocol: rpcv2,
87+
documentation: "Client should accept CBOR empty struct if no output",
88+
headers: {
89+
"smithy-protocol": "rpc-v2-cbor",
90+
"Accept": "application/cbor",
91+
"Content-Type": "application/cbor"
92+
}
93+
body: "v/8=",
94+
code: 200,
95+
appliesTo: "client",
96+
}
97+
])
98+
operation NoInputOutput {}
99+
100+
101+
@httpRequestTests([
102+
{
103+
id: "empty_input",
104+
protocol: rpcv2,
105+
documentation: "When Input structure is empty we write CBOR equivalent of {}",
106+
headers: {
107+
"smithy-protocol": "rpc-v2-cbor",
108+
"Accept": "application/cbor",
109+
"Content-Type": "application/cbor"
110+
},
111+
forbidHeaders: [
112+
"X-Amz-Target"
113+
]
114+
method: "POST",
115+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/EmptyInputOutput",
116+
body: "v/8=",
117+
},
118+
])
119+
@httpResponseTests([
120+
{
121+
id: "empty_output",
122+
protocol: rpcv2,
123+
documentation: "When output structure is empty we write CBOR equivalent of {}",
124+
body: "v/8=",
125+
bodyMediaType: "application/cbor",
126+
headers: {
127+
"smithy-protocol": "rpc-v2-cbor",
128+
"Content-Type": "application/cbor"
129+
}
130+
code: 200,
131+
},
132+
])
133+
operation EmptyInputOutput {
134+
input: EmptyStructure,
135+
output: EmptyStructure
136+
}
137+
138+
@httpRequestTests([
139+
{
140+
id: "optional_input",
141+
protocol: rpcv2,
142+
documentation: "When input is empty we write CBOR equivalent of {}",
143+
headers: {
144+
"smithy-protocol": "rpc-v2-cbor",
145+
"Accept": "application/cbor",
146+
"Content-Type": "application/cbor"
147+
},
148+
forbidHeaders: [
149+
"X-Amz-Target"
150+
]
151+
method: "POST",
152+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/OptionalInputOutput",
153+
body: "v/8=",
154+
},
155+
])
156+
@httpResponseTests([
157+
{
158+
id: "optional_output",
159+
protocol: rpcv2,
160+
documentation: "When output is empty we write CBOR equivalent of {}",
161+
body: "v/8=",
162+
bodyMediaType: "application/cbor",
163+
headers: {
164+
"smithy-protocol": "rpc-v2-cbor",
165+
"Content-Type": "application/cbor"
166+
}
167+
code: 200,
168+
},
169+
])
170+
operation OptionalInputOutput {
171+
input: SimpleStructure,
172+
output: SimpleStructure
173+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$version: "2.0"
2+
3+
namespace aws.protocoltests.rpcv2
4+
use aws.api#service
5+
use smithy.protocols#rpcv2
6+
use smithy.test#httpRequestTests
7+
use smithy.test#httpResponseTests
8+
9+
@service(sdkId: "Sample RpcV2 Protocol")
10+
@rpcv2(format: ["cbor"])
11+
@title("RpcV2 Protocol Service")
12+
service RpcV2Protocol {
13+
version: "2020-07-14",
14+
operations: [
15+
//Basic input/output tests
16+
NoInputOutput,
17+
EmptyInputOutput,
18+
OptionalInputOutput,
19+
20+
SimpleScalarProperties,
21+
]
22+
}
23+
24+
structure EmptyStructure {
25+
26+
}
27+
28+
structure SimpleStructure {
29+
value: String,
30+
}

0 commit comments

Comments
 (0)