Skip to content

Add query-compatible protocol tests #3896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"core": {
"updateMinimum": true,
"type": "patch",
"changeLogMessages": [
"Add new protocol tests. Update JSON response unmarshallers to return safely if the service returns an empty string as a response instead of an empty json body"
]
}
}
2 changes: 1 addition & 1 deletion generator/ProtocolTestsGenerator/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pluginManagement {
dependencyResolutionManagement {
versionCatalogs {
create("codegen") {
version("smithy", "1.54.0")
version("smithy", "1.60.3")
library("protocol-tests", "software.amazon.smithy", "smithy-aws-protocol-tests").versionRef("smithy")
library("codegen-core", "software.amazon.smithy", "smithy-codegen-core").versionRef("smithy")
library("protocol-tests-traits", "software.amazon.smithy", "smithy-protocol-test-traits").versionRef("smithy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ private void generateErrorResponseTests(OperationShape operation, OperationIndex
for (StructureShape error : index.getErrors(operation, service)) {
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
generateErrorResponseTest(operation, error, httpResponseTestCase);
if (!ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId())){
generateErrorResponseTest(operation, error, httpResponseTestCase);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ private ProtocolTestCustomizations() {
// to use exceptions and control flow.
"QueryEmptyInputAndEmptyOutput",
"QueryNoInputAndNoOutput",
"QueryNoInputAndOutput"
"QueryNoInputAndOutput",
// this test is skipped because in the C2J Ruby added a hook which adds the "code" json key which can NEVER exist in a
// non-query protocol. this causes our code generation to check on this code instead of what is modeled and our protocol
// test passes. As this can never happen in a real service, we can skip this to avoid unnecessary customizations in the generator
// for a scenario that will never happen.
"QueryCompatibleAwsJson10CustomCodeError"
);
public static final List<String> VNextTests = Arrays.asList(
//These are the tests that are failing in v4 after updating to 1.54.0 and artifacts 1.0.3004.0. Each one needs to be investigated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@
"packageVersion": "0.0.1"
}
}
},
"QueryCompatibleJSONRPC10": {
"transforms": [
{
"name": "includeServices",
"args": {
"services": [
"aws.protocoltests.json10#QueryCompatibleJsonRpc10"
]
}
}
],
"plugins": {
"dotnet-protocol-test-codegen": {
"service": "aws.protocoltests.json10#QueryCompatibleJsonRpc10",
"packageVersion": "0.0.1"
}
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
#>
StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
if (reader.Reader.IsFinalBlock) return response;
var unmarshaller = <#= payload.DetermineTypeUnmarshallerInstantiate() #>;
response.<#=payload.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
"input":{"shape":"PutWithContentEncodingInput"},
"requestcompression":{"encodings":["gzip"]}
},
"QueryIncompatibleOperation":{
"name":"QueryIncompatibleOperation",
"http":{
"method":"POST",
"requestUri":"/"
},
"idempotent":true
},
"SimpleScalarProperties":{
"name":"SimpleScalarProperties",
"http":{
Expand Down Expand Up @@ -153,22 +161,19 @@
},
"ContentTypeParametersOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"Double":{
"type":"double",
"box":true
},
"EmptyInputAndEmptyOutputInput":{
"type":"structure",
"members":{
}
"members":{}
},
"EmptyInputAndEmptyOutputOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"EndpointWithHostLabelOperationInput":{
"type":"structure",
Expand Down Expand Up @@ -196,8 +201,7 @@
},
"FooError":{
"type":"structure",
"members":{
},
"members":{},
"documentation":"<p>This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.</p>",
"exception":true,
"fault":true
Expand Down Expand Up @@ -267,8 +271,7 @@
},
"NoInputAndOutputOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"PutWithContentEncodingInput":{
"type":"structure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@
},
"ContentTypeParametersOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"DateTime":{
"type":"timestamp",
Expand All @@ -226,8 +225,7 @@
},
"Document":{
"type":"structure",
"members":{
},
"members":{},
"document":true
},
"Double":{
Expand All @@ -236,8 +234,7 @@
},
"EmptyStruct":{
"type":"structure",
"members":{
}
"members":{}
},
"ErrorWithMembers":{
"type":"structure",
Expand All @@ -257,8 +254,7 @@
},
"ErrorWithoutMembers":{
"type":"structure",
"members":{
},
"members":{},
"exception":true,
"fault":true
},
Expand Down Expand Up @@ -291,8 +287,7 @@
},
"FooError":{
"type":"structure",
"members":{
},
"members":{},
"documentation":"<p>This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.</p>",
"exception":true,
"fault":true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"active": true,
"test-service": true,
"synopsis": "query-compatible test service"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"version":"2.0",
"metadata":{
"apiVersion":"2020-07-14",
"auth":["aws.auth#sigv4"],
"awsQueryCompatible":{},
"endpointPrefix":"query-compatible-jsonrpc10",
"jsonVersion":"1.0",
"protocol":"json",
"protocols":["json"],
"serviceFullName":"Query Compatible Json 1.0 Protocol Service",
"serviceId":"Query Compatible JSON RPC 10",
"signatureVersion":"v4",
"signingName":"query-compatible-jsonrpc10",
"targetPrefix":"QueryCompatibleJsonRpc10",
"uid":"query-compatible-json-rpc-10-2020-07-14"
},
"operations":{
"QueryCompatibleOperation":{
"name":"QueryCompatibleOperation",
"http":{
"method":"POST",
"requestUri":"/"
},
"errors":[
{"shape":"CustomCodeError"},
{"shape":"NoCustomCodeError"}
],
"idempotent":true
}
},
"shapes":{
"CustomCodeError":{
"type":"structure",
"members":{
"message":{"shape":"String"}
},
"error":{
"code":"Customized",
"httpStatusCode":402,
"senderFault":true
},
"exception":true
},
"NoCustomCodeError":{
"type":"structure",
"members":{
"message":{"shape":"String"}
},
"exception":true
},
"String":{"type":"string"}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@
"documentation":"<p>This example tests httpChecksumRequired trait</p>",
"httpChecksumRequired":true
},
"HttpEmptyPrefixHeaders":{
"name":"HttpEmptyPrefixHeaders",
"http":{
"method":"GET",
"requestUri":"/HttpEmptyPrefixHeaders",
"responseCode":200
},
"input":{"shape":"HttpEmptyPrefixHeadersInput"},
"output":{"shape":"HttpEmptyPrefixHeadersOutput"},
"documentation":"<p>Clients that perform this test extract all headers from the response.</p>"
},
"HttpEnumPayload":{
"name":"HttpEnumPayload",
"http":{
Expand Down Expand Up @@ -854,8 +865,7 @@
},
"ContentTypeParametersOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"DateTime":{
"type":"timestamp",
Expand Down Expand Up @@ -894,8 +904,7 @@
},
"Document":{
"type":"structure",
"members":{
},
"members":{},
"document":true
},
"DocumentTypeAsMapValueInputOutput":{
Expand Down Expand Up @@ -933,13 +942,11 @@
},
"EmptyInputAndEmptyOutputInput":{
"type":"structure",
"members":{
}
"members":{}
},
"EmptyInputAndEmptyOutputOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"EnumPayloadInput":{
"type":"structure",
Expand Down Expand Up @@ -981,8 +988,7 @@
},
"FooError":{
"type":"structure",
"members":{
},
"members":{},
"documentation":"<p>This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.</p>",
"error":{"httpStatusCode":500},
"exception":true,
Expand Down Expand Up @@ -1030,6 +1036,36 @@
"type":"timestamp",
"timestampFormat":"rfc822"
},
"HttpEmptyPrefixHeadersInput":{
"type":"structure",
"members":{
"prefixHeaders":{
"shape":"StringMap",
"location":"headers",
"locationName":""
},
"specificHeader":{
"shape":"String",
"location":"header",
"locationName":"hello"
}
}
},
"HttpEmptyPrefixHeadersOutput":{
"type":"structure",
"members":{
"prefixHeaders":{
"shape":"StringMap",
"location":"headers",
"locationName":""
},
"specificHeader":{
"shape":"String",
"location":"header",
"locationName":"hello"
}
}
},
"HttpPayloadTraitsInputOutput":{
"type":"structure",
"members":{
Expand Down Expand Up @@ -1058,8 +1094,7 @@
},
"HttpPrefixHeadersInResponseInput":{
"type":"structure",
"members":{
}
"members":{}
},
"HttpPrefixHeadersInResponseOutput":{
"type":"structure",
Expand Down Expand Up @@ -1536,8 +1571,7 @@
},
"NoInputAndOutputOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"NullAndEmptyHeadersIO":{
"type":"structure",
Expand Down Expand Up @@ -1711,8 +1745,7 @@
},
"ResponseCodeHttpFallbackInputOutput":{
"type":"structure",
"members":{
}
"members":{}
},
"ResponseCodeRequiredOutput":{
"type":"structure",
Expand Down
Loading