Skip to content

Commit f39f70c

Browse files
authored
Add query compatible protocol tests. Fix broken protocol tests (#3898)
* Add cw protocol tests * Updates to protocol test generator and generator * Add latest c2j files, generated file updates, and generated protocol tests * Add query compatible to netstandard sln and protocol tests csproj * remove unnecessary comment
1 parent 2a644a4 commit f39f70c

File tree

231 files changed

+98295
-5581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+98295
-5581
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"core": {
3+
"changeLogMessages": [
4+
"Update to consume latest protocol tests (1.60.3). Add query compatible protocol tests."
5+
],
6+
"type": "patch",
7+
"updateMinimum": true
8+
}
9+
}

generator/ProtocolTestsGenerator/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pluginManagement {
1212
dependencyResolutionManagement {
1313
versionCatalogs {
1414
create("codegen") {
15-
version("smithy", "1.46.0")
15+
version("smithy", "1.60.3")
1616
library("protocol-tests", "software.amazon.smithy", "smithy-aws-protocol-tests").versionRef("smithy")
1717
library("codegen-core", "software.amazon.smithy", "smithy-codegen-core").versionRef("smithy")
1818
library("protocol-tests-traits", "software.amazon.smithy", "smithy-protocol-test-traits").versionRef("smithy")

generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ private void generateErrorResponseTest(OperationShape operation, StructureShape
110110
writer.write("[TestCategory(\"ErrorTest\")]");
111111
writer.write("[TestCategory(\"$L\")]", serviceName);
112112
writer.openBlock("public void $LErrorResponse()\n{", "}", httpResponseTestCase.getId(), () -> {
113-
generateErrorResponseTestBlock(operation, error, httpResponseTestCase);
113+
if (!ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId())){
114+
generateErrorResponseTest(operation, error, httpResponseTestCase);
115+
}
114116
});
115117
writer.write("\n");
116118
}
@@ -151,7 +153,7 @@ private void generateRequestTests(OperationShape operation) {
151153
setMarshallerType(trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName());
152154
}
153155
for (HttpRequestTestCase httpRequestTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
154-
if (ProtocolTestCustomizations.TestsToSkip.contains(httpRequestTestCase.getId()))
156+
if (ProtocolTestCustomizations.TestsToSkip.contains(httpRequestTestCase.getId()) || httpRequestTestCase.hasTag("defaults"))
155157
continue;
156158
generateRequestTest(operation, httpRequestTestCase);
157159
}
@@ -295,7 +297,7 @@ private void generateResponseTests(OperationShape operation) {
295297
setMarshallerType(trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName());
296298
}
297299
for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
298-
if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()))
300+
if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()) || httpResponseTestCase.hasTag("defaults"))
299301
continue;
300302
generateResponseTest(operation, httpResponseTestCase);
301303
}

generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ private ProtocolTestCustomizations() {
1212
//These contain collections with nullable values
1313
public static final List<String> RestJsonNullMapValueOperations = Arrays.asList(
1414
"JsonMapsRequest",
15-
"JsonMapsResponse"
15+
"JsonMapsResponse",
16+
"SparseJsonMapsRequest",
17+
"SparseJsonMapsResponse"
1618
);
1719
public static final List<String> RestJsonNullMapValueStructures = Arrays.asList(
1820
"SparseBooleanMap",
@@ -88,7 +90,12 @@ private ProtocolTestCustomizations() {
8890
"XmlUnionsWithStructMember",
8991
"XmlUnionsWithStringMember",
9092
"XmlUnionsWithBooleanMember",
91-
"XmlUnionsWithUnionMember"
93+
"XmlUnionsWithUnionMember",
94+
// this test is skipped because in the C2J Ruby added a hook which adds the "code" json key which can NEVER exist in a
95+
// non-query protocol. this causes our code generation to check on this code instead of what is modeled and our protocol
96+
// test passes. As this can never happen in a real service, we can skip this to avoid unnecessary customizations in the generator
97+
// for a scenario that will never happen.
98+
"QueryCompatibleAwsJson10CustomCodeError"
9299

93100
);
94101
public static final List<String> VNextTests = Arrays.asList(
@@ -122,6 +129,11 @@ private ProtocolTestCustomizations() {
122129
"QueryNoInputAndNoOutput",
123130
"QueryNoInputAndOutput",
124131
"RestJsonToleratesRegexCharsInSegments",
125-
"RestXmlXmlMapWithXmlNamespace"
132+
"RestXmlXmlMapWithXmlNamespace",
133+
"NestedXmlMapWithXmlNameSerializes",
134+
"NestedXmlMapWithXmlNameDeserializes",
135+
"RestJsonNullAndEmptyHeaders",
136+
"NullAndEmptyHeaders",
137+
"RestJsonHttpPayloadWithStructureAndEmptyResponseBody"
126138
);
127139
}

generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@
127127
"packageVersion": "0.0.1"
128128
}
129129
}
130+
},
131+
"QueryCompatibleJSONRPC10": {
132+
"transforms": [
133+
{
134+
"name": "includeServices",
135+
"args": {
136+
"services": [
137+
"aws.protocoltests.json10#QueryCompatibleJsonRpc10"
138+
]
139+
}
140+
}
141+
],
142+
"plugins": {
143+
"dotnet-protocol-test-codegen": {
144+
"service": "aws.protocoltests.json10#QueryCompatibleJsonRpc10",
145+
"packageVersion": "0.0.1"
146+
}
147+
}
130148
}
131149
}
132150
}

0 commit comments

Comments
 (0)