Skip to content

Commit 22fe304

Browse files
committed
Basic protocol tests
1 parent cc3eda2 commit 22fe304

File tree

5 files changed

+346
-1
lines changed

5 files changed

+346
-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: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
stringValue: "simple"
34+
}
35+
},
36+
{
37+
id: "RpcV2CborClientDoesntSerializeNullStructureValues",
38+
documentation: "RpcV2 Cbor should not serialize null structure values",
39+
protocol: rpcv2,
40+
method: "POST",
41+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties",
42+
body: "v/8=",
43+
bodyMediaType: "application/cbor",
44+
headers: {
45+
"smithy-protocol": "rpc-v2-cbor",
46+
"Accept": "application/cbor",
47+
"Content-Type": "application/cbor"
48+
}
49+
params: {
50+
stringValue: null
51+
},
52+
appliesTo: "client"
53+
},
54+
{
55+
id: "RpcV2CborServerDoesntDeSerializeNullStructureValues",
56+
documentation: "RpcV2 Cbor should not deserialize null structure values",
57+
protocol: rpcv2,
58+
method: "POST",
59+
uri: "/service/aws.protocoltests.rpcv2.RpcV2Protocol/operation/SimpleScalarProperties",
60+
body: "v2tzdHJpbmdWYWx1Zfb/",
61+
bodyMediaType: "application/cbor",
62+
headers: {
63+
"smithy-protocol": "rpc-v2-cbor",
64+
"Accept": "application/cbor",
65+
"Content-Type": "application/cbor"
66+
}
67+
params: {},
68+
appliesTo: "server"
69+
},
70+
])
71+
@httpResponseTests([
72+
{
73+
id: "simple_scalar_structure",
74+
protocol: rpcv2,
75+
documentation: "Serializes simple scalar properties",
76+
headers: {
77+
"smithy-protocol": "rpc-v2-cbor",
78+
"Content-Type": "application/cbor"
79+
}
80+
bodyMediaType: "application/cbor",
81+
body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=",
82+
code: 200,
83+
params: {
84+
trueBooleanValue: true,
85+
falseBooleanValue: false,
86+
byteValue: 5,
87+
doubleValue: 1.889,
88+
floatValue: 7.624,
89+
integerValue: 256,
90+
shortValue: 9898,
91+
stringValue: "simple"
92+
}
93+
},
94+
{
95+
id: "RpcV2CborClientDoesntDeSerializeNullStructureValues",
96+
documentation: "RpcV2 Cbor should deserialize null structure values",
97+
protocol: rpcv2,
98+
body: "v2tzdHJpbmdWYWx1Zfb/",
99+
code: 200,
100+
bodyMediaType: "application/cbor",
101+
headers: {
102+
"smithy-protocol": "rpc-v2-cbor",
103+
"Content-Type": "application/cbor"
104+
}
105+
params: {}
106+
appliesTo: "client"
107+
},
108+
{
109+
id: "RpcV2CborServerDoesntSerializeNullStructureValues",
110+
documentation: "RpcV2 Cbor should not serialize null structure values",
111+
protocol: rpcv2,
112+
body: "v/8=",
113+
code: 200,
114+
bodyMediaType: "application/cbor",
115+
headers: {
116+
"smithy-protocol": "rpc-v2-cbor",
117+
"Content-Type": "application/cbor"
118+
}
119+
params: {
120+
stringValue: null
121+
},
122+
appliesTo: "server"
123+
},
124+
])
125+
operation SimpleScalarProperties {
126+
input: SimpleScalarStructure,
127+
output: SimpleScalarStructure
128+
}
129+
130+
131+
structure SimpleScalarStructure {
132+
trueBooleanValue: Boolean,
133+
falseBooleanValue: Boolean,
134+
byteValue: Byte,
135+
doubleValue: Double,
136+
floatValue: Float,
137+
integerValue: Integer,
138+
longValue: Long,
139+
shortValue: Short,
140+
stringValue: String,
141+
}
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: "",
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)