From 1ca1f8ae726d6836c94e17d58f437755fcc74790 Mon Sep 17 00:00:00 2001 From: Matteo Bigoi <1781140+crisidev@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:36:28 +0000 Subject: [PATCH 01/30] Add Smithy RPC v2 trait (#1583) * Add Smithy RPC v2 trait definition and implementation Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com> * Add support for wire formats * Address PR comments * Rename SmithyRpcV2* to just Rpcv2 * Finish refactor to just have Rpcv2 * Address PR comments. Remove the validator for now * Address comments from PR --------- Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com> --- .gitignore | 3 + settings.gradle | 1 + smithy-protocols-traits/README.md | 7 + smithy-protocols-traits/build.gradle | 26 +++ .../smithy/protocols/traits/Rpcv2Trait.java | 198 ++++++++++++++++++ .../smithy/protocols/traits/package-info.java | 22 ++ ...re.amazon.smithy.model.traits.TraitService | 1 + .../main/resources/META-INF/smithy/manifest | 1 + .../smithy/smithy.protocols.rpcv2.smithy | 33 +++ .../protocols/traits/Rpcv2TraitTest.java | 40 ++++ 10 files changed, 332 insertions(+) create mode 100644 smithy-protocols-traits/README.md create mode 100644 smithy-protocols-traits/build.gradle create mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java create mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java create mode 100644 smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService create mode 100644 smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest create mode 100644 smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy create mode 100644 smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java diff --git a/.gitignore b/.gitignore index 4b608569e63..ed1c10be16a 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,8 @@ build/ */*/out/ /wrapper +# jdt-ls +.metadata + # Smithy .smithy.lsp.log diff --git a/settings.gradle b/settings.gradle index bc0abdddc09..67e5cf0801a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -34,3 +34,4 @@ include ":smithy-smoke-test-traits" include ":smithy-syntax" include ":smithy-aws-endpoints" include ":smithy-aws-smoke-test-model" +include ":smithy-protocols-traits" diff --git a/smithy-protocols-traits/README.md b/smithy-protocols-traits/README.md new file mode 100644 index 00000000000..51d00fe62b1 --- /dev/null +++ b/smithy-protocols-traits/README.md @@ -0,0 +1,7 @@ +# Smithy protocols traits + +This module provides the implementation of protocols traits for Smithy. + +Protocols: + +* RPC v2 - An RPC protocol with support for multiple wire formats. diff --git a/smithy-protocols-traits/build.gradle b/smithy-protocols-traits/build.gradle new file mode 100644 index 00000000000..6bbd3dacf16 --- /dev/null +++ b/smithy-protocols-traits/build.gradle @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +description = "This module provides the implementation of protocols traits for Smithy." + +ext { + displayName = "Smithy :: Protocols Traits" + moduleName = "software.amazon.smithy.protocols.traits" +} + +dependencies { + api project(":smithy-utils") + api project(":smithy-model") +} diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java new file mode 100644 index 00000000000..9d48fd0a192 --- /dev/null +++ b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java @@ -0,0 +1,198 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.smithy.protocols.traits; + +import java.util.ArrayList; +import java.util.List; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.AbstractTrait; +import software.amazon.smithy.model.traits.AbstractTraitBuilder; +import software.amazon.smithy.utils.ListUtils; + +public final class Rpcv2Trait extends AbstractTrait { + + private static final String HTTP = "http"; + private static final String EVENT_STREAM_HTTP = "eventStreamHttp"; + private static final String FORMAT = "format"; + + private final List http; + private final List eventStreamHttp; + private final List format; + + public static final ShapeId ID = ShapeId.from("smithy.protocols#rpcv2"); + + // Package-private constructor (at least for now) + Rpcv2Trait(Builder builder) { + super(ID, builder.getSourceLocation()); + http = ListUtils.copyOf(builder.http); + eventStreamHttp = ListUtils.copyOf(builder.eventStreamHttp); + format = ListUtils.copyOf(builder.format); + } + + /** + * Gets the priority ordered list of supported HTTP protocol versions. + * + * @return Returns the supported HTTP protocol versions. + */ + public List getHttp() { + return http; + } + + /** + * Gets the priority ordered list of supported HTTP protocol versions + * that are required when using event streams. + * + * @return Returns the supported event stream HTTP protocol versions. + */ + public List getEventStreamHttp() { + return eventStreamHttp; + } + + /** + * Gets the priority ordered list of supported wire formats. + * + * @return Returns the supported wire formats. + */ + public List getFormat() { + return format; + } + + /** + * Turns the trait into a {@code Node} + */ + @Override + protected Node createNode() { + ObjectNode.Builder builder = Node.objectNodeBuilder(); + + if (!getHttp().isEmpty()) { + builder.withMember(HTTP, Node.fromStrings(getHttp())); + } + + if (!getEventStreamHttp().isEmpty()) { + builder.withMember(EVENT_STREAM_HTTP, Node.fromStrings(getEventStreamHttp())); + } + + if (!getFormat().isEmpty()) { + builder.withMember(FORMAT, Node.fromStrings(getFormat())); + } + + return builder.build(); + } + + /** + * Builder for creating a {@code Rpcv2Trait}. + */ + public static final class Builder extends AbstractTraitBuilder { + + private final List http = new ArrayList<>(); + private final List eventStreamHttp = new ArrayList<>(); + private final List format = new ArrayList<>(); + + + @Override + public Rpcv2Trait build() { + return new Rpcv2Trait(this); + } + + /** + * Sets the list of supported HTTP protocols. + * + * @param http HTTP protocols to set and replace. + * @return Returns the builder. + */ + public Builder http(List http) { + this.http.clear(); + this.http.addAll(http); + return this; + } + + /** + * Sets the list of supported event stream HTTP protocols. + * + * @param eventStreamHttp Event stream HTTP protocols to set and replace. + * @return Returns the builder. + */ + public Builder eventStreamHttp(List eventStreamHttp) { + this.eventStreamHttp.clear(); + this.eventStreamHttp.addAll(eventStreamHttp); + return this; + } + + /** + * Sets the list of supported wire formats. + * + * @param format Wire format to set and replace. + * @return Returns the builder. + */ + public Builder format(List format) { + this.format.clear(); + this.format.addAll(format); + return this; + } + + /** + * Updates the builder from a Node. + * + * @param node Node object that must be a valid {@code ObjectNode}. + * @return Returns the updated builder. + */ + public Builder fromNode(Node node) { + ObjectNode objectNode = node.expectObjectNode(); + objectNode.getArrayMember(HTTP) + .map(values -> Node.loadArrayOfString(HTTP, values)) + .ifPresent(this::http); + objectNode.getArrayMember(EVENT_STREAM_HTTP) + .map(values -> Node.loadArrayOfString(EVENT_STREAM_HTTP, values)) + .ifPresent(this::eventStreamHttp); + objectNode.getArrayMember(FORMAT) + .map(values -> Node.loadArrayOfString(FORMAT, values)) + .ifPresent(this::format); + + return this; + } + } + + /** + * Creates a new {@code Builder}. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Implements the {@code AbstractTrait.Provider}. + */ + public static final class Provider extends AbstractTrait.Provider { + + public Provider() { + super(ID); + } + + /** + * Creates a trait from a {@code Node} value. + * + * @param shapeId The shape ID. + * @param value The Node value. + * @return Returns the Rpcv2Trait. + */ + @Override + public Rpcv2Trait createTrait(ShapeId shapeId, Node value) { + return builder().sourceLocation(value).fromNode(value).build(); + } + } +} diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java new file mode 100644 index 00000000000..36881ad898c --- /dev/null +++ b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java @@ -0,0 +1,22 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/** + * Defines protocols for Smithy. + */ +@SmithyUnstableApi +package software.amazon.smithy.protocols.traits; + +import software.amazon.smithy.utils.SmithyUnstableApi; diff --git a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService new file mode 100644 index 00000000000..8da69972e45 --- /dev/null +++ b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService @@ -0,0 +1 @@ +software.amazon.smithy.protocols.traits.Rpcv2Trait$Provider diff --git a/smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest b/smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest new file mode 100644 index 00000000000..d3ce2c739ec --- /dev/null +++ b/smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest @@ -0,0 +1 @@ +smithy.protocols.rpcv2.smithy diff --git a/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy b/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy new file mode 100644 index 00000000000..7ca3b57b63f --- /dev/null +++ b/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy @@ -0,0 +1,33 @@ +$version: "2.0" + +namespace smithy.protocols + +use smithy.api#httpError +use smithy.api#cors +use smithy.api#endpoint +use smithy.api#hostLabel + +/// An RPC protocol with support for multiple wire formats. +@trait(selector: "service") +@protocolDefinition(traits: [ + httpError + cors + endpoint + hostLabel +]) +structure rpcv2 { + /// Priority ordered list of supported HTTP protocol versions. + http: StringList + /// Priority ordered list of supported HTTP protocol versions + /// that are required when using event streams. + eventStreamHttp: StringList + + /// Priority ordered list of supported wire formats. + @required + format: StringList +} + +/// A list of String shapes. +list StringList { + member: String +} diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java new file mode 100644 index 00000000000..a97c988e31d --- /dev/null +++ b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.smithy.protocols.traits; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.Trait; +import software.amazon.smithy.model.traits.TraitFactory; + +import java.util.Optional; + +public class Rpcv2TraitTest { + + @Test + public void loadsTraitWithDefaults() { + Node node = Node.objectNode(); + TraitFactory provider = TraitFactory.createServiceFactory(); + Optional trait = provider.createTrait(Rpcv2Trait.ID, ShapeId.from("ns.foo#foo"), node); + + Assertions.assertTrue(trait.isPresent()); + Assertions.assertTrue(trait.get() instanceof Rpcv2Trait); + Rpcv2Trait smithyRpcV2Trait = (Rpcv2Trait) trait.get(); + Assertions.assertEquals(smithyRpcV2Trait.toNode(), node); + } +} From a5adb18c00c3906370fabeba151a769285d10e0b Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:46:34 +0000 Subject: [PATCH 02/30] Make rpcv2 StringList @private --- .../main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy | 1 + 1 file changed, 1 insertion(+) diff --git a/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy b/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy index 7ca3b57b63f..0f76da8ad4c 100644 --- a/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy +++ b/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy @@ -28,6 +28,7 @@ structure rpcv2 { } /// A list of String shapes. +@private list StringList { member: String } From 7eb9d90a6f7d3cbeec7745fffe55ab7f8d854a06 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:29:29 +0000 Subject: [PATCH 03/30] Format code --- .../smithy/protocols/traits/Rpcv2Trait.java | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java index 9d48fd0a192..b4a98a9d672 100644 --- a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java +++ b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java @@ -1,20 +1,18 @@ /* * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except + * in compliance with the License. A copy of the License is located at * - * http://aws.amazon.com/apache2.0 + * http://aws.amazon.com/apache2.0 * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package software.amazon.smithy.protocols.traits; - + import java.util.ArrayList; import java.util.List; import software.amazon.smithy.model.node.Node; @@ -26,6 +24,8 @@ public final class Rpcv2Trait extends AbstractTrait { + public static final ShapeId ID = ShapeId.from("smithy.protocols#rpcv2"); + private static final String HTTP = "http"; private static final String EVENT_STREAM_HTTP = "eventStreamHttp"; private static final String FORMAT = "format"; @@ -34,8 +34,6 @@ public final class Rpcv2Trait extends AbstractTrait { private final List eventStreamHttp; private final List format; - public static final ShapeId ID = ShapeId.from("smithy.protocols#rpcv2"); - // Package-private constructor (at least for now) Rpcv2Trait(Builder builder) { super(ID, builder.getSourceLocation()); @@ -54,8 +52,8 @@ public List getHttp() { } /** - * Gets the priority ordered list of supported HTTP protocol versions - * that are required when using event streams. + * Gets the priority ordered list of supported HTTP protocol versions that are required when + * using event streams. * * @return Returns the supported event stream HTTP protocol versions. */ @@ -73,7 +71,7 @@ public List getFormat() { } /** - * Turns the trait into a {@code Node} + * Turns the trait into a {@code Node}. */ @Override protected Node createNode() { @@ -153,16 +151,14 @@ public Builder format(List format) { */ public Builder fromNode(Node node) { ObjectNode objectNode = node.expectObjectNode(); - objectNode.getArrayMember(HTTP) - .map(values -> Node.loadArrayOfString(HTTP, values)) + objectNode.getArrayMember(HTTP).map(values -> Node.loadArrayOfString(HTTP, values)) .ifPresent(this::http); objectNode.getArrayMember(EVENT_STREAM_HTTP) .map(values -> Node.loadArrayOfString(EVENT_STREAM_HTTP, values)) .ifPresent(this::eventStreamHttp); - objectNode.getArrayMember(FORMAT) - .map(values -> Node.loadArrayOfString(FORMAT, values)) + objectNode.getArrayMember(FORMAT).map(values -> Node.loadArrayOfString(FORMAT, values)) .ifPresent(this::format); - + return this; } } @@ -178,17 +174,17 @@ public static Builder builder() { * Implements the {@code AbstractTrait.Provider}. */ public static final class Provider extends AbstractTrait.Provider { - + public Provider() { super(ID); } - + /** * Creates a trait from a {@code Node} value. * * @param shapeId The shape ID. * @param value The Node value. - * @return Returns the Rpcv2Trait. + * @return Returns the Rpcv2Trait. */ @Override public Rpcv2Trait createTrait(ShapeId shapeId, Node value) { From cb78b01ab6f999918fa6d8f7691df246a758da68 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:31:15 +0000 Subject: [PATCH 04/30] Format also tests --- .../smithy/protocols/traits/Rpcv2TraitTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java index a97c988e31d..4bb02f4ebaa 100644 --- a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java +++ b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java @@ -1,16 +1,14 @@ /* * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except + * in compliance with the License. A copy of the License is located at * - * http://aws.amazon.com/apache2.0 + * http://aws.amazon.com/apache2.0 * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package software.amazon.smithy.protocols.traits; @@ -30,7 +28,8 @@ public class Rpcv2TraitTest { public void loadsTraitWithDefaults() { Node node = Node.objectNode(); TraitFactory provider = TraitFactory.createServiceFactory(); - Optional trait = provider.createTrait(Rpcv2Trait.ID, ShapeId.from("ns.foo#foo"), node); + Optional trait = + provider.createTrait(Rpcv2Trait.ID, ShapeId.from("ns.foo#foo"), node); Assertions.assertTrue(trait.isPresent()); Assertions.assertTrue(trait.get() instanceof Rpcv2Trait); From 89adadc9074a4804f95a52b7898a68400c984e28 Mon Sep 17 00:00:00 2001 From: kstich Date: Thu, 9 Feb 2023 11:09:21 -0800 Subject: [PATCH 05/30] Enable CI on rpcv2 branch --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de2607dbab2..f86ffc8a63c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: ci on: push: - branches: [main] + branches: [main, smithy-rpc-v2] pull_request: - branches: [main] + branches: [main, smithy-rpc-v2] jobs: build: From 2fb046a477c66d788f4209a7e57f040c17aa49f8 Mon Sep 17 00:00:00 2001 From: Matteo Bigoi <1781140+crisidev@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:27:04 +0000 Subject: [PATCH 06/30] Implement Rpcv2TraitValidator and tests (#1613) * Implement Rpcv2TraitValidator and tests * Add missing license * Update smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java Co-authored-by: Kevin Stich * Address comments from PR * Make sure format is always set * Fix typo * Fix comment * Fix comment * Fix trailing whitespace --------- Co-authored-by: Kevin Stich --- .../smithy/protocols/traits/Rpcv2Trait.java | 6 +- .../protocols/traits/Rpcv2TraitValidator.java | 80 +++++++++++++++++++ ...e.amazon.smithy.model.validation.Validator | 1 + .../protocols/traits/Rpcv2TraitTest.java | 3 +- .../protocols/traits/TestRunnerTest.java | 34 ++++++++ .../traits/errorfiles/cbor-wire-format.errors | 4 + .../traits/errorfiles/cbor-wire-format.smithy | 30 +++++++ .../eventStreamHttp-matches-http.errors | 3 + .../eventStreamHttp-matches-http.smithy | 40 ++++++++++ 9 files changed, 196 insertions(+), 5 deletions(-) create mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java create mode 100644 smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator create mode 100644 smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java create mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors create mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy create mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors create mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java index b4a98a9d672..37bd68fab74 100644 --- a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java +++ b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java @@ -85,9 +85,9 @@ protected Node createNode() { builder.withMember(EVENT_STREAM_HTTP, Node.fromStrings(getEventStreamHttp())); } - if (!getFormat().isEmpty()) { - builder.withMember(FORMAT, Node.fromStrings(getFormat())); - } + // Build the format property even if it's empty as the {@code Rpcv2TraitValidator} + // will take care of validating it. + builder.withMember(FORMAT, Node.fromStrings(getFormat())); return builder.build(); } diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java new file mode 100644 index 00000000000..85f83a8260d --- /dev/null +++ b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java @@ -0,0 +1,80 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except + * in compliance with the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package software.amazon.smithy.protocols.traits; + +import java.util.ArrayList; +import java.util.List; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ServiceShape; +import software.amazon.smithy.model.validation.AbstractValidator; +import software.amazon.smithy.model.validation.ValidationEvent; +import software.amazon.smithy.utils.ListUtils; +import software.amazon.smithy.utils.SmithyInternalApi; + +/** + * Validates models implementing the {@code Rpcv2Trait} against its constraints by: + * + * - Ensuring that every entry in {@code eventStreamHttp} also appears in the {@code http} property + * of a protocol trait. + * - Ensuring that there is at least one value for the {@code format} property. + * - Ensuring all the {@code format} property values are valid and supported. + */ +@SmithyInternalApi +public final class Rpcv2TraitValidator extends AbstractValidator { + + private static final List VALID_FORMATS = ListUtils.of("cbor"); + + @Override + public List validate(Model model) { + List events = new ArrayList<>(); + for (ServiceShape serviceShape : model.getServiceShapesWithTrait(Rpcv2Trait.class)) { + events.addAll(validateService(serviceShape)); + } + return events; + } + + private List validateService(ServiceShape service) { + List events = new ArrayList<>(); + + Rpcv2Trait protocolTrait = service.expectTrait(Rpcv2Trait.class); + + List invalid = new ArrayList<>(protocolTrait.getEventStreamHttp()); + invalid.removeAll(protocolTrait.getHttp()); + if (!invalid.isEmpty()) { + events.add(error(service, protocolTrait, + String.format("The following values of the `eventStreamHttp` property do " + + "not also appear in the `http` property of the %s protocol " + + "trait: %s", protocolTrait.toShapeId(), invalid))); + } + + List formats = new ArrayList<>(protocolTrait.getFormat()); + // Validate there is at least one element in the format property. + if (formats.size() == 0) { + events.add(error(service, protocolTrait, String.format( + "The `format` property for the %s protocol must have at least 1 element", + protocolTrait.toShapeId()))); + } + // All the user specified wire formats must be valid. + formats.removeAll(VALID_FORMATS); + if (!formats.isEmpty()) { + events.add(error(service, protocolTrait, + String.format( + "The following values of the `format` property for the %s protocol " + + "are not supported: %s", + protocolTrait.toShapeId(), formats)));; + } + + return events; + } +} diff --git a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator new file mode 100644 index 00000000000..c1afb055be9 --- /dev/null +++ b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -0,0 +1 @@ +software.amazon.smithy.protocols.traits.Rpcv2TraitValidator diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java index 4bb02f4ebaa..21d52dafcef 100644 --- a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java +++ b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java @@ -19,14 +19,13 @@ import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.Trait; import software.amazon.smithy.model.traits.TraitFactory; - import java.util.Optional; public class Rpcv2TraitTest { @Test public void loadsTraitWithDefaults() { - Node node = Node.objectNode(); + Node node = Node.objectNode().withMember("format", Node.fromStrings("cbor")); TraitFactory provider = TraitFactory.createServiceFactory(); Optional trait = provider.createTrait(Rpcv2Trait.ID, ShapeId.from("ns.foo#foo"), node); diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java new file mode 100644 index 00000000000..706b58c4e8b --- /dev/null +++ b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except + * in compliance with the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package software.amazon.smithy.protocols.traits; + +import java.util.concurrent.Callable; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import software.amazon.smithy.model.validation.testrunner.SmithyTestCase; +import software.amazon.smithy.model.validation.testrunner.SmithyTestSuite; + +public class TestRunnerTest { + @ParameterizedTest(name = "{0}") + @MethodSource("source") + public void testRunner(String filename, Callable callable) + throws Exception { + callable.call(); + } + + public static Stream source() { + return SmithyTestSuite.defaultParameterizedTestSource(TestRunnerTest.class); + } +} diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors new file mode 100644 index 00000000000..3be7bc74d3b --- /dev/null +++ b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors @@ -0,0 +1,4 @@ +[ERROR] smithy.example#InvalidService1: The `format` property for the smithy.protocols#rpcv2 protocol must have at least 1 element | Rpcv2Trait +[ERROR] smithy.example#InvalidService2: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format] | Rpcv2Trait +[ERROR] smithy.example#InvalidService3: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format] | Rpcv2Trait +[ERROR] smithy.example#InvalidService4: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format1, invalid-wire-format2] | Rpcv2Trait diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy new file mode 100644 index 00000000000..01e97b955be --- /dev/null +++ b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy @@ -0,0 +1,30 @@ +$version: "2.0" + +namespace smithy.example + +use smithy.protocols#rpcv2 + +@rpcv2(format: ["cbor"]) +service ValidService1 { + version: "2023-02-10" +} + +@rpcv2(format: []) +service InvalidService1 { + version: "2023-02-10" +} + +@rpcv2(format: ["invalid-wire-format"]) +service InvalidService2 { + version: "2023-02-10" +} + +@rpcv2(format: ["cbor", "invalid-wire-format"]) +service InvalidService3 { + version: "2023-02-10" +} + +@rpcv2(format: ["invalid-wire-format1", "invalid-wire-format2"]) +service InvalidService4 { + version: "2023-02-10" +} diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors new file mode 100644 index 00000000000..bf90e0e4214 --- /dev/null +++ b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors @@ -0,0 +1,3 @@ +[ERROR] smithy.example#InvalidService1: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1] | Rpcv2Trait +[ERROR] smithy.example#InvalidService2: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1] | Rpcv2Trait +[ERROR] smithy.example#InvalidService3: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1, h2c] | Rpcv2Trait diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy new file mode 100644 index 00000000000..5dcef0c674f --- /dev/null +++ b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy @@ -0,0 +1,40 @@ +$version: "2.0" + +namespace smithy.example + +use smithy.protocols#rpcv2 + +@rpcv2(http: ["h2", "http/1.1"], eventStreamHttp: ["h2"], format: ["cbor"]) +service ValidService1 { + version: "2023-02-10" +} + +@rpcv2(http: ["h2"], eventStreamHttp: ["h2"], format: ["cbor"]) +service ValidService2 { + version: "2023-02-10" +} + +@rpcv2(http: [], eventStreamHttp: [], format: ["cbor"]) +service ValidService3 { + version: "2023-02-10" +} + +@rpcv2(http: ["http/1.1"], eventStreamHttp: [], format: ["cbor"]) +service ValidService4 { + version: "2023-02-10" +} + +@rpcv2(eventStreamHttp: ["http/1.1"], format: ["cbor"]) +service InvalidService1 { + version: "2023-02-10" +} + +@rpcv2(http: ["h2"], eventStreamHttp: ["http/1.1"], format: ["cbor"]) +service InvalidService2 { + version: "2023-02-10" +} + +@rpcv2(http: ["h2"], eventStreamHttp: ["h2", "http/1.1", "h2c"], format: ["cbor"]) +service InvalidService3 { + version: "2023-02-10" +} From 716f82eeea84d0ed16216cb8b33ece1027bbca9e Mon Sep 17 00:00:00 2001 From: kstich Date: Tue, 2 Jan 2024 16:05:20 -0800 Subject: [PATCH 07/30] Move to CBOR trait from configured formats This commit refactors the trait implementation to be specific to the CBOR wire format instead of taking a collection of possible wire formats, simplifying the process of resolving the protocol to use for generated code. It also moves the package to `smithy-protocol-traits`, removing the pluralization on `protocols`. --- settings.gradle | 2 +- .../README.md | 0 smithy-protocol-traits/build.gradle | 16 ++ .../protocol/traits/Rpcv2CborTrait.java | 148 +++++++++++++ .../traits/Rpcv2CborTraitValidator.java | 42 ++++ .../smithy/protocol/traits/package-info.java | 12 ++ ...re.amazon.smithy.model.traits.TraitService | 1 + ...e.amazon.smithy.model.validation.Validator | 1 + .../main/resources/META-INF/smithy/manifest | 0 .../smithy/smithy.protocols.rpcv2.smithy | 13 +- .../protocol/traits/Rpcv2CborTraitTest.java | 29 +++ .../protocol}/traits/TestRunnerTest.java | 14 +- .../eventStreamHttp-matches-http.errors | 6 +- .../eventStreamHttp-matches-http.smithy | 40 ++++ smithy-protocols-traits/build.gradle | 26 --- .../smithy/protocols/traits/Rpcv2Trait.java | 194 ------------------ .../protocols/traits/Rpcv2TraitValidator.java | 80 -------- .../smithy/protocols/traits/package-info.java | 22 -- ...re.amazon.smithy.model.traits.TraitService | 1 - ...e.amazon.smithy.model.validation.Validator | 1 - .../protocols/traits/Rpcv2TraitTest.java | 38 ---- .../traits/errorfiles/cbor-wire-format.errors | 4 - .../traits/errorfiles/cbor-wire-format.smithy | 30 --- .../eventStreamHttp-matches-http.smithy | 40 ---- 24 files changed, 301 insertions(+), 459 deletions(-) rename {smithy-protocols-traits => smithy-protocol-traits}/README.md (100%) create mode 100644 smithy-protocol-traits/build.gradle create mode 100644 smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTrait.java create mode 100644 smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitValidator.java create mode 100644 smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/package-info.java create mode 100644 smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService create mode 100644 smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator rename {smithy-protocols-traits => smithy-protocol-traits}/src/main/resources/META-INF/smithy/manifest (100%) rename {smithy-protocols-traits => smithy-protocol-traits}/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy (76%) create mode 100644 smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitTest.java rename {smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols => smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol}/traits/TestRunnerTest.java (53%) rename {smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols => smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol}/traits/errorfiles/eventStreamHttp-matches-http.errors (59%) create mode 100644 smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.smithy delete mode 100644 smithy-protocols-traits/build.gradle delete mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java delete mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java delete mode 100644 smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java delete mode 100644 smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService delete mode 100644 smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator delete mode 100644 smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java delete mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors delete mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy delete mode 100644 smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy diff --git a/settings.gradle b/settings.gradle index 67e5cf0801a..b2b2da0b6b1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -34,4 +34,4 @@ include ":smithy-smoke-test-traits" include ":smithy-syntax" include ":smithy-aws-endpoints" include ":smithy-aws-smoke-test-model" -include ":smithy-protocols-traits" +include ":smithy-protocol-traits" diff --git a/smithy-protocols-traits/README.md b/smithy-protocol-traits/README.md similarity index 100% rename from smithy-protocols-traits/README.md rename to smithy-protocol-traits/README.md diff --git a/smithy-protocol-traits/build.gradle b/smithy-protocol-traits/build.gradle new file mode 100644 index 00000000000..c269a7e007a --- /dev/null +++ b/smithy-protocol-traits/build.gradle @@ -0,0 +1,16 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +description = "This module provides the implementation of protocol traits for Smithy." + +ext { + displayName = "Smithy :: Protocol Traits" + moduleName = "software.amazon.smithy.protocol.traits" +} + +dependencies { + api project(":smithy-utils") + api project(":smithy-model") +} diff --git a/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTrait.java b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTrait.java new file mode 100644 index 00000000000..af9a5ee8907 --- /dev/null +++ b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTrait.java @@ -0,0 +1,148 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.protocol.traits; + +import java.util.ArrayList; +import java.util.List; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.node.ObjectNode; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.AbstractTrait; +import software.amazon.smithy.model.traits.AbstractTraitBuilder; +import software.amazon.smithy.model.traits.Trait; +import software.amazon.smithy.utils.ListUtils; +import software.amazon.smithy.utils.ToSmithyBuilder; + +public final class Rpcv2CborTrait extends AbstractTrait implements ToSmithyBuilder { + + public static final ShapeId ID = ShapeId.from("smithy.protocols#rpcv2Cbor"); + + private static final String HTTP = "http"; + private static final String EVENT_STREAM_HTTP = "eventStreamHttp"; + + private final List http; + private final List eventStreamHttp; + + private Rpcv2CborTrait(Builder builder) { + super(ID, builder.getSourceLocation()); + http = ListUtils.copyOf(builder.http); + eventStreamHttp = ListUtils.copyOf(builder.eventStreamHttp); + } + + /** + * Creates a new {@code Builder}. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Updates the builder from a Node. + * + * @param node Node object that must be a valid {@code ObjectNode}. + * @return Returns the updated builder. + */ + public static Rpcv2CborTrait fromNode(Node node) { + Builder builder = builder().sourceLocation(node); + ObjectNode objectNode = node.expectObjectNode(); + objectNode.getArrayMember(HTTP).map(values -> Node.loadArrayOfString(HTTP, values)) + .ifPresent(builder::http); + objectNode.getArrayMember(EVENT_STREAM_HTTP).map(values -> Node.loadArrayOfString(EVENT_STREAM_HTTP, values)) + .ifPresent(builder::eventStreamHttp); + return builder.build(); + } + + /** + * Gets the priority ordered list of supported HTTP protocol versions. + * + * @return Returns the supported HTTP protocol versions. + */ + public List getHttp() { + return http; + } + + /** + * Gets the priority ordered list of supported HTTP protocol versions that are required when + * using event streams. + * + * @return Returns the supported event stream HTTP protocol versions. + */ + public List getEventStreamHttp() { + return eventStreamHttp; + } + + @Override + protected Node createNode() { + ObjectNode.Builder builder = Node.objectNodeBuilder().sourceLocation(getSourceLocation()); + if (!getHttp().isEmpty()) { + builder.withMember(HTTP, Node.fromStrings(getHttp())); + } + if (!getEventStreamHttp().isEmpty()) { + builder.withMember(EVENT_STREAM_HTTP, Node.fromStrings(getEventStreamHttp())); + } + return builder.build(); + } + + @Override + public Builder toBuilder() { + return builder().http(http).eventStreamHttp(eventStreamHttp); + } + + /** + * Builder for creating a {@code Rpcv2CborTrait}. + */ + public static final class Builder extends AbstractTraitBuilder { + + private final List http = new ArrayList<>(); + private final List eventStreamHttp = new ArrayList<>(); + + @Override + public Rpcv2CborTrait build() { + return new Rpcv2CborTrait(this); + } + + /** + * Sets the list of supported HTTP protocols. + * + * @param http HTTP protocols to set and replace. + * @return Returns the builder. + */ + public Builder http(List http) { + this.http.clear(); + this.http.addAll(http); + return this; + } + + /** + * Sets the list of supported event stream HTTP protocols. + * + * @param eventStreamHttp Event stream HTTP protocols to set and replace. + * @return Returns the builder. + */ + public Builder eventStreamHttp(List eventStreamHttp) { + this.eventStreamHttp.clear(); + this.eventStreamHttp.addAll(eventStreamHttp); + return this; + } + } + + /** + * Implements the {@code AbstractTrait.Provider}. + */ + public static final class Provider extends AbstractTrait.Provider { + + public Provider() { + super(ID); + } + + @Override + public Trait createTrait(ShapeId target, Node value) { + Rpcv2CborTrait result = fromNode(value); + result.setNodeCache(value); + return result; + } + } +} diff --git a/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitValidator.java b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitValidator.java new file mode 100644 index 00000000000..e8049bd959a --- /dev/null +++ b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitValidator.java @@ -0,0 +1,42 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.protocol.traits; + +import java.util.ArrayList; +import java.util.List; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ServiceShape; +import software.amazon.smithy.model.validation.AbstractValidator; +import software.amazon.smithy.model.validation.ValidationEvent; +import software.amazon.smithy.utils.SmithyInternalApi; + +/** + * Validates models implementing the {@code Rpcv2CborTrait} against its constraints by: + * + * - Ensuring that every entry in {@code eventStreamHttp} also appears in the {@code http} property + * of a protocol trait. + */ +@SmithyInternalApi +public final class Rpcv2CborTraitValidator extends AbstractValidator { + + @Override + public List validate(Model model) { + List events = new ArrayList<>(); + for (ServiceShape serviceShape : model.getServiceShapesWithTrait(Rpcv2CborTrait.class)) { + Rpcv2CborTrait protocolTrait = serviceShape.expectTrait(Rpcv2CborTrait.class); + + List invalid = new ArrayList<>(protocolTrait.getEventStreamHttp()); + invalid.removeAll(protocolTrait.getHttp()); + if (!invalid.isEmpty()) { + events.add(error(serviceShape, protocolTrait, + String.format("The following values of the `eventStreamHttp` property do " + + "not also appear in the `http` property of the %s protocol " + + "trait: %s", protocolTrait.toShapeId(), invalid))); + } + } + return events; + } +} diff --git a/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/package-info.java b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/package-info.java new file mode 100644 index 00000000000..38e4b7cf8b1 --- /dev/null +++ b/smithy-protocol-traits/src/main/java/software/amazon/smithy/protocol/traits/package-info.java @@ -0,0 +1,12 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * Defines protocols for Smithy. + */ +@SmithyUnstableApi +package software.amazon.smithy.protocol.traits; + +import software.amazon.smithy.utils.SmithyUnstableApi; diff --git a/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService b/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService new file mode 100644 index 00000000000..807dd17ce19 --- /dev/null +++ b/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService @@ -0,0 +1 @@ +software.amazon.smithy.protocol.traits.Rpcv2CborTrait$Provider diff --git a/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator new file mode 100644 index 00000000000..d764d47b993 --- /dev/null +++ b/smithy-protocol-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator @@ -0,0 +1 @@ +software.amazon.smithy.protocol.traits.Rpcv2CborTraitValidator diff --git a/smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest b/smithy-protocol-traits/src/main/resources/META-INF/smithy/manifest similarity index 100% rename from smithy-protocols-traits/src/main/resources/META-INF/smithy/manifest rename to smithy-protocol-traits/src/main/resources/META-INF/smithy/manifest diff --git a/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy similarity index 76% rename from smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy rename to smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy index 0f76da8ad4c..8fb2d37e5cc 100644 --- a/smithy-protocols-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy +++ b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy @@ -2,29 +2,26 @@ $version: "2.0" namespace smithy.protocols -use smithy.api#httpError use smithy.api#cors use smithy.api#endpoint use smithy.api#hostLabel +use smithy.api#httpError -/// An RPC protocol with support for multiple wire formats. +/// An RPC-based protocol that serializes CBOR payloads. @trait(selector: "service") @protocolDefinition(traits: [ - httpError cors endpoint hostLabel + httpError ]) -structure rpcv2 { +structure rpcv2Cbor { /// Priority ordered list of supported HTTP protocol versions. http: StringList + /// Priority ordered list of supported HTTP protocol versions /// that are required when using event streams. eventStreamHttp: StringList - - /// Priority ordered list of supported wire formats. - @required - format: StringList } /// A list of String shapes. diff --git a/smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitTest.java b/smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitTest.java new file mode 100644 index 00000000000..5897863b2bd --- /dev/null +++ b/smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/Rpcv2CborTraitTest.java @@ -0,0 +1,29 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.protocol.traits; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.smithy.model.node.Node; +import software.amazon.smithy.model.shapes.ShapeId; +import software.amazon.smithy.model.traits.Trait; +import software.amazon.smithy.model.traits.TraitFactory; +import java.util.Optional; + +public class Rpcv2CborTraitTest { + + @Test + public void loadsTraitWithDefaults() { + Node node = Node.objectNode(); + TraitFactory provider = TraitFactory.createServiceFactory(); + Optional trait = provider.createTrait(Rpcv2CborTrait.ID, ShapeId.from("ns.foo#foo"), node); + + Assertions.assertTrue(trait.isPresent()); + Assertions.assertTrue(trait.get() instanceof Rpcv2CborTrait); + Rpcv2CborTrait smithyRpcV2Trait = (Rpcv2CborTrait) trait.get(); + Assertions.assertEquals(smithyRpcV2Trait.toNode(), node); + } +} diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java b/smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/TestRunnerTest.java similarity index 53% rename from smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java rename to smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/TestRunnerTest.java index 706b58c4e8b..8c29bfe12c8 100644 --- a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/TestRunnerTest.java +++ b/smithy-protocol-traits/src/test/java/software/amazon/smithy/protocol/traits/TestRunnerTest.java @@ -1,17 +1,9 @@ /* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except - * in compliance with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ -package software.amazon.smithy.protocols.traits; +package software.amazon.smithy.protocol.traits; import java.util.concurrent.Callable; import java.util.stream.Stream; diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.errors similarity index 59% rename from smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors rename to smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.errors index bf90e0e4214..5f569df65f3 100644 --- a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.errors +++ b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.errors @@ -1,3 +1,3 @@ -[ERROR] smithy.example#InvalidService1: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1] | Rpcv2Trait -[ERROR] smithy.example#InvalidService2: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1] | Rpcv2Trait -[ERROR] smithy.example#InvalidService3: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2 protocol trait: [http/1.1, h2c] | Rpcv2Trait +[ERROR] smithy.example#InvalidService1: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2Cbor protocol trait: [http/1.1] | Rpcv2CborTrait +[ERROR] smithy.example#InvalidService2: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2Cbor protocol trait: [http/1.1] | Rpcv2CborTrait +[ERROR] smithy.example#InvalidService3: The following values of the `eventStreamHttp` property do not also appear in the `http` property of the smithy.protocols#rpcv2Cbor protocol trait: [http/1.1, h2c] | Rpcv2CborTrait diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.smithy b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.smithy new file mode 100644 index 00000000000..5f0968710e5 --- /dev/null +++ b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/eventStreamHttp-matches-http.smithy @@ -0,0 +1,40 @@ +$version: "2.0" + +namespace smithy.example + +use smithy.protocols#rpcv2Cbor + +@rpcv2Cbor(http: ["h2", "http/1.1"], eventStreamHttp: ["h2"]) +service ValidService1 { + version: "2023-02-10" +} + +@rpcv2Cbor(http: ["h2"], eventStreamHttp: ["h2"]) +service ValidService2 { + version: "2023-02-10" +} + +@rpcv2Cbor(http: [], eventStreamHttp: []) +service ValidService3 { + version: "2023-02-10" +} + +@rpcv2Cbor(http: ["http/1.1"], eventStreamHttp: []) +service ValidService4 { + version: "2023-02-10" +} + +@rpcv2Cbor(eventStreamHttp: ["http/1.1"]) +service InvalidService1 { + version: "2023-02-10" +} + +@rpcv2Cbor(http: ["h2"], eventStreamHttp: ["http/1.1"]) +service InvalidService2 { + version: "2023-02-10" +} + +@rpcv2Cbor(http: ["h2"], eventStreamHttp: ["h2", "http/1.1", "h2c"]) +service InvalidService3 { + version: "2023-02-10" +} diff --git a/smithy-protocols-traits/build.gradle b/smithy-protocols-traits/build.gradle deleted file mode 100644 index 6bbd3dacf16..00000000000 --- a/smithy-protocols-traits/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -description = "This module provides the implementation of protocols traits for Smithy." - -ext { - displayName = "Smithy :: Protocols Traits" - moduleName = "software.amazon.smithy.protocols.traits" -} - -dependencies { - api project(":smithy-utils") - api project(":smithy-model") -} diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java deleted file mode 100644 index 37bd68fab74..00000000000 --- a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2Trait.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except - * in compliance with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package software.amazon.smithy.protocols.traits; - -import java.util.ArrayList; -import java.util.List; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.node.ObjectNode; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.AbstractTrait; -import software.amazon.smithy.model.traits.AbstractTraitBuilder; -import software.amazon.smithy.utils.ListUtils; - -public final class Rpcv2Trait extends AbstractTrait { - - public static final ShapeId ID = ShapeId.from("smithy.protocols#rpcv2"); - - private static final String HTTP = "http"; - private static final String EVENT_STREAM_HTTP = "eventStreamHttp"; - private static final String FORMAT = "format"; - - private final List http; - private final List eventStreamHttp; - private final List format; - - // Package-private constructor (at least for now) - Rpcv2Trait(Builder builder) { - super(ID, builder.getSourceLocation()); - http = ListUtils.copyOf(builder.http); - eventStreamHttp = ListUtils.copyOf(builder.eventStreamHttp); - format = ListUtils.copyOf(builder.format); - } - - /** - * Gets the priority ordered list of supported HTTP protocol versions. - * - * @return Returns the supported HTTP protocol versions. - */ - public List getHttp() { - return http; - } - - /** - * Gets the priority ordered list of supported HTTP protocol versions that are required when - * using event streams. - * - * @return Returns the supported event stream HTTP protocol versions. - */ - public List getEventStreamHttp() { - return eventStreamHttp; - } - - /** - * Gets the priority ordered list of supported wire formats. - * - * @return Returns the supported wire formats. - */ - public List getFormat() { - return format; - } - - /** - * Turns the trait into a {@code Node}. - */ - @Override - protected Node createNode() { - ObjectNode.Builder builder = Node.objectNodeBuilder(); - - if (!getHttp().isEmpty()) { - builder.withMember(HTTP, Node.fromStrings(getHttp())); - } - - if (!getEventStreamHttp().isEmpty()) { - builder.withMember(EVENT_STREAM_HTTP, Node.fromStrings(getEventStreamHttp())); - } - - // Build the format property even if it's empty as the {@code Rpcv2TraitValidator} - // will take care of validating it. - builder.withMember(FORMAT, Node.fromStrings(getFormat())); - - return builder.build(); - } - - /** - * Builder for creating a {@code Rpcv2Trait}. - */ - public static final class Builder extends AbstractTraitBuilder { - - private final List http = new ArrayList<>(); - private final List eventStreamHttp = new ArrayList<>(); - private final List format = new ArrayList<>(); - - - @Override - public Rpcv2Trait build() { - return new Rpcv2Trait(this); - } - - /** - * Sets the list of supported HTTP protocols. - * - * @param http HTTP protocols to set and replace. - * @return Returns the builder. - */ - public Builder http(List http) { - this.http.clear(); - this.http.addAll(http); - return this; - } - - /** - * Sets the list of supported event stream HTTP protocols. - * - * @param eventStreamHttp Event stream HTTP protocols to set and replace. - * @return Returns the builder. - */ - public Builder eventStreamHttp(List eventStreamHttp) { - this.eventStreamHttp.clear(); - this.eventStreamHttp.addAll(eventStreamHttp); - return this; - } - - /** - * Sets the list of supported wire formats. - * - * @param format Wire format to set and replace. - * @return Returns the builder. - */ - public Builder format(List format) { - this.format.clear(); - this.format.addAll(format); - return this; - } - - /** - * Updates the builder from a Node. - * - * @param node Node object that must be a valid {@code ObjectNode}. - * @return Returns the updated builder. - */ - public Builder fromNode(Node node) { - ObjectNode objectNode = node.expectObjectNode(); - objectNode.getArrayMember(HTTP).map(values -> Node.loadArrayOfString(HTTP, values)) - .ifPresent(this::http); - objectNode.getArrayMember(EVENT_STREAM_HTTP) - .map(values -> Node.loadArrayOfString(EVENT_STREAM_HTTP, values)) - .ifPresent(this::eventStreamHttp); - objectNode.getArrayMember(FORMAT).map(values -> Node.loadArrayOfString(FORMAT, values)) - .ifPresent(this::format); - - return this; - } - } - - /** - * Creates a new {@code Builder}. - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Implements the {@code AbstractTrait.Provider}. - */ - public static final class Provider extends AbstractTrait.Provider { - - public Provider() { - super(ID); - } - - /** - * Creates a trait from a {@code Node} value. - * - * @param shapeId The shape ID. - * @param value The Node value. - * @return Returns the Rpcv2Trait. - */ - @Override - public Rpcv2Trait createTrait(ShapeId shapeId, Node value) { - return builder().sourceLocation(value).fromNode(value).build(); - } - } -} diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java deleted file mode 100644 index 85f83a8260d..00000000000 --- a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/Rpcv2TraitValidator.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except - * in compliance with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package software.amazon.smithy.protocols.traits; - -import java.util.ArrayList; -import java.util.List; -import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.shapes.ServiceShape; -import software.amazon.smithy.model.validation.AbstractValidator; -import software.amazon.smithy.model.validation.ValidationEvent; -import software.amazon.smithy.utils.ListUtils; -import software.amazon.smithy.utils.SmithyInternalApi; - -/** - * Validates models implementing the {@code Rpcv2Trait} against its constraints by: - * - * - Ensuring that every entry in {@code eventStreamHttp} also appears in the {@code http} property - * of a protocol trait. - * - Ensuring that there is at least one value for the {@code format} property. - * - Ensuring all the {@code format} property values are valid and supported. - */ -@SmithyInternalApi -public final class Rpcv2TraitValidator extends AbstractValidator { - - private static final List VALID_FORMATS = ListUtils.of("cbor"); - - @Override - public List validate(Model model) { - List events = new ArrayList<>(); - for (ServiceShape serviceShape : model.getServiceShapesWithTrait(Rpcv2Trait.class)) { - events.addAll(validateService(serviceShape)); - } - return events; - } - - private List validateService(ServiceShape service) { - List events = new ArrayList<>(); - - Rpcv2Trait protocolTrait = service.expectTrait(Rpcv2Trait.class); - - List invalid = new ArrayList<>(protocolTrait.getEventStreamHttp()); - invalid.removeAll(protocolTrait.getHttp()); - if (!invalid.isEmpty()) { - events.add(error(service, protocolTrait, - String.format("The following values of the `eventStreamHttp` property do " - + "not also appear in the `http` property of the %s protocol " - + "trait: %s", protocolTrait.toShapeId(), invalid))); - } - - List formats = new ArrayList<>(protocolTrait.getFormat()); - // Validate there is at least one element in the format property. - if (formats.size() == 0) { - events.add(error(service, protocolTrait, String.format( - "The `format` property for the %s protocol must have at least 1 element", - protocolTrait.toShapeId()))); - } - // All the user specified wire formats must be valid. - formats.removeAll(VALID_FORMATS); - if (!formats.isEmpty()) { - events.add(error(service, protocolTrait, - String.format( - "The following values of the `format` property for the %s protocol " - + "are not supported: %s", - protocolTrait.toShapeId(), formats)));; - } - - return events; - } -} diff --git a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java b/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java deleted file mode 100644 index 36881ad898c..00000000000 --- a/smithy-protocols-traits/src/main/java/software/amazon/smithy/protocols/traits/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -/** - * Defines protocols for Smithy. - */ -@SmithyUnstableApi -package software.amazon.smithy.protocols.traits; - -import software.amazon.smithy.utils.SmithyUnstableApi; diff --git a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService deleted file mode 100644 index 8da69972e45..00000000000 --- a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.traits.TraitService +++ /dev/null @@ -1 +0,0 @@ -software.amazon.smithy.protocols.traits.Rpcv2Trait$Provider diff --git a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator b/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator deleted file mode 100644 index c1afb055be9..00000000000 --- a/smithy-protocols-traits/src/main/resources/META-INF/services/software.amazon.smithy.model.validation.Validator +++ /dev/null @@ -1 +0,0 @@ -software.amazon.smithy.protocols.traits.Rpcv2TraitValidator diff --git a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java b/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java deleted file mode 100644 index 21d52dafcef..00000000000 --- a/smithy-protocols-traits/src/test/java/software/amazon/smithy/protocols/traits/Rpcv2TraitTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except - * in compliance with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package software.amazon.smithy.protocols.traits; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import software.amazon.smithy.model.node.Node; -import software.amazon.smithy.model.shapes.ShapeId; -import software.amazon.smithy.model.traits.Trait; -import software.amazon.smithy.model.traits.TraitFactory; -import java.util.Optional; - -public class Rpcv2TraitTest { - - @Test - public void loadsTraitWithDefaults() { - Node node = Node.objectNode().withMember("format", Node.fromStrings("cbor")); - TraitFactory provider = TraitFactory.createServiceFactory(); - Optional trait = - provider.createTrait(Rpcv2Trait.ID, ShapeId.from("ns.foo#foo"), node); - - Assertions.assertTrue(trait.isPresent()); - Assertions.assertTrue(trait.get() instanceof Rpcv2Trait); - Rpcv2Trait smithyRpcV2Trait = (Rpcv2Trait) trait.get(); - Assertions.assertEquals(smithyRpcV2Trait.toNode(), node); - } -} diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors deleted file mode 100644 index 3be7bc74d3b..00000000000 --- a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.errors +++ /dev/null @@ -1,4 +0,0 @@ -[ERROR] smithy.example#InvalidService1: The `format` property for the smithy.protocols#rpcv2 protocol must have at least 1 element | Rpcv2Trait -[ERROR] smithy.example#InvalidService2: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format] | Rpcv2Trait -[ERROR] smithy.example#InvalidService3: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format] | Rpcv2Trait -[ERROR] smithy.example#InvalidService4: The following values of the `format` property for the smithy.protocols#rpcv2 protocol are not supported: [invalid-wire-format1, invalid-wire-format2] | Rpcv2Trait diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy deleted file mode 100644 index 01e97b955be..00000000000 --- a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/cbor-wire-format.smithy +++ /dev/null @@ -1,30 +0,0 @@ -$version: "2.0" - -namespace smithy.example - -use smithy.protocols#rpcv2 - -@rpcv2(format: ["cbor"]) -service ValidService1 { - version: "2023-02-10" -} - -@rpcv2(format: []) -service InvalidService1 { - version: "2023-02-10" -} - -@rpcv2(format: ["invalid-wire-format"]) -service InvalidService2 { - version: "2023-02-10" -} - -@rpcv2(format: ["cbor", "invalid-wire-format"]) -service InvalidService3 { - version: "2023-02-10" -} - -@rpcv2(format: ["invalid-wire-format1", "invalid-wire-format2"]) -service InvalidService4 { - version: "2023-02-10" -} diff --git a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy b/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy deleted file mode 100644 index 5dcef0c674f..00000000000 --- a/smithy-protocols-traits/src/test/resources/software/amazon/smithy/protocols/traits/errorfiles/eventStreamHttp-matches-http.smithy +++ /dev/null @@ -1,40 +0,0 @@ -$version: "2.0" - -namespace smithy.example - -use smithy.protocols#rpcv2 - -@rpcv2(http: ["h2", "http/1.1"], eventStreamHttp: ["h2"], format: ["cbor"]) -service ValidService1 { - version: "2023-02-10" -} - -@rpcv2(http: ["h2"], eventStreamHttp: ["h2"], format: ["cbor"]) -service ValidService2 { - version: "2023-02-10" -} - -@rpcv2(http: [], eventStreamHttp: [], format: ["cbor"]) -service ValidService3 { - version: "2023-02-10" -} - -@rpcv2(http: ["http/1.1"], eventStreamHttp: [], format: ["cbor"]) -service ValidService4 { - version: "2023-02-10" -} - -@rpcv2(eventStreamHttp: ["http/1.1"], format: ["cbor"]) -service InvalidService1 { - version: "2023-02-10" -} - -@rpcv2(http: ["h2"], eventStreamHttp: ["http/1.1"], format: ["cbor"]) -service InvalidService2 { - version: "2023-02-10" -} - -@rpcv2(http: ["h2"], eventStreamHttp: ["h2", "http/1.1", "h2c"], format: ["cbor"]) -service InvalidService3 { - version: "2023-02-10" -} From 09b3396d38c93b9e37b0cc8e97abc45891417992 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Mon, 11 Mar 2024 00:12:48 -0700 Subject: [PATCH 08/30] Add spec for Smithy RPC v2 --- docs/source-2.0/additional-specs/index.rst | 1 + .../additional-specs/protocols/index.rst | 10 + .../protocols/smithy-rpc-v2.rst | 484 ++++++++++++++++++ .../aws/protocols/aws-query-protocol.rst | 28 +- 4 files changed, 512 insertions(+), 11 deletions(-) create mode 100644 docs/source-2.0/additional-specs/protocols/index.rst create mode 100644 docs/source-2.0/additional-specs/protocols/smithy-rpc-v2.rst diff --git a/docs/source-2.0/additional-specs/index.rst b/docs/source-2.0/additional-specs/index.rst index cf3743324a3..e9c8638b4a6 100644 --- a/docs/source-2.0/additional-specs/index.rst +++ b/docs/source-2.0/additional-specs/index.rst @@ -15,6 +15,7 @@ start with ``smithy.*`` where "*" is anything other than ``api``. waiters mqtt rules-engine/index + protocols/index .. seealso:: diff --git a/docs/source-2.0/additional-specs/protocols/index.rst b/docs/source-2.0/additional-specs/protocols/index.rst new file mode 100644 index 00000000000..9d41bef0040 --- /dev/null +++ b/docs/source-2.0/additional-specs/protocols/index.rst @@ -0,0 +1,10 @@ +.. _protocols: + +========= +Protocols +========= + +.. toctree:: + :maxdepth: 1 + + smithy-rpc-v2 diff --git a/docs/source-2.0/additional-specs/protocols/smithy-rpc-v2.rst b/docs/source-2.0/additional-specs/protocols/smithy-rpc-v2.rst new file mode 100644 index 00000000000..2b2e4664bda --- /dev/null +++ b/docs/source-2.0/additional-specs/protocols/smithy-rpc-v2.rst @@ -0,0 +1,484 @@ +.. _smithy-rpc-v2-cbor: + +=========================== +Smithy RPC v2 CBOR protocol +=========================== + +This specification defines the ``smithy.protocols#rpcv2Cbor`` protocol. This +protocol is used to expose services that serialize RPC payloads as CBOR. + +.. smithy-trait:: smithy.protocols#rpcv2Cbor +.. _smithy.protocols#rpcv2Cbor-trait: + + +------------------------------------ +``smithy.protocols#rpcv2Cbor`` trait +------------------------------------ + +Summary + Adds support for an RPC-based protocol over HTTP that sends requests and + responses with CBOR payloads. +Trait selector + ``service`` +Value type + Structure +See + `Protocol tests `_ + +``smithy.protocols#rpcv2Cbor`` is a structure that supports the following +members: + +.. list-table:: + :header-rows: 1 + :widths: 10 20 70 + + * - Property + - Type + - Description + * - http + - ``[string]`` + - The priority ordered list of supported HTTP protocol versions. + * - eventStreamHttp + - ``[string]`` + - The priority ordered list of supported HTTP protocol versions + that are required when using :ref:`event streams ` + with the service. If not set, this value defaults to the value + of the ``http`` member. Any entry in ``eventStreamHttp`` MUST + also appear in ``http``. + +Each entry in ``http`` and ``eventStreamHttp`` SHOULD be a valid +`Application-Layer Protocol Negotiation (ALPN) Protocol ID`_ (for example, +``http/1.1``, ``h2``, etc). Clients SHOULD pick the first protocol in the +list they understand when connecting to a service. A client SHOULD assume +that a service supports ``http/1.1`` when no ``http`` or ``eventStreamHttp`` +values are provided. + +The following example defines a service that uses +``smithy.protocols#rpcv2Cbor``. + +.. code-block:: smithy + + $version: "2" + + namespace smithy.example + + use smithy.protocols#rpcv2Cbor + + @rpcv2Cbor + service MyService { + version: "2020-07-02" + } + +The following example defines a service that requires the use of +``h2`` when using event streams. + +.. code-block:: smithy + + $version: "2" + + namespace smithy.example + + use smithy.protocols#rpcv2Cbor + + @rpcv2Cbor( + http: ["h2", "http/1.1"], + eventStreamHttp: ["h2"] + ) + service MyService { + version: "2020-02-05" + } + +The following example defines a service that requires the use of +``h2`` or ``http/1.1`` when using event streams, where ``h2`` is +preferred over ``http/1.1``. + +.. code-block:: smithy + + $version: "2" + + namespace smithy.example + + use smithy.protocols#rpcv2Cbor + + @rpcv2Cbor( + http: ["h2", "http/1.1"], + eventStreamHttp: ["h2", "http/1.1"] + ) + service MyService { + version: "2020-02-05" + } + +The following example defines a service that requires the use of +``h2`` for all requests, including event streams. + +.. code-block:: smithy + + $version: "2" + + namespace smithy.example + + use smithy.protocols#rpcv2Cbor + + @rpcv2Cbor(http: ["h2"]) + service MyService { + version: "2020-02-05" + } + + +---------------- +Supported traits +---------------- + +The ``smithy.protocols#rpcv2Cbor`` protocol supports the following traits +that affect serialization: + +.. list-table:: + :header-rows: 1 + :widths: 20 80 + + * - Trait + - Description + * - :ref:`cors ` + - Indicates that the service supports CORS. + * - :ref:`endpoint ` + - Configures a custom operation endpoint. + * - :ref:`hostLabel ` + - Binds a top-level operation input structure member to a label in + the hostPrefix of an endpoint trait. + * - :ref:`httpError ` + - A ``client`` error has a default status code of ``400``, and a + ``server`` error has a default status code of ``500``. The + ``httpError`` trait is used to define a custom status code. + * - :ref:`requestCompression ` + - Indicates that an operation supports compressing requests from clients + to services. + + +------------------ +Protocol behaviors +------------------ + +Implementations of the ``smithy.protocols#rpcv2Cbor`` protocol comply with the +following rules: + +~~~~~~~~ +Requests +~~~~~~~~ + +Every request for the ``rpcv2Cbor`` protocol MUST contain a ``Smithy-Protocol`` +header with the value of ``rpc-v2-cbor``. + +Every request for the ``rpcv2Cbor`` protocol MUST be sent using the HTTP +``POST`` method. :ref:`HTTP binding traits ` MUST be ignored when +building ``rpcv2Cbor`` requests if they are present. + +Every request for the ``rpcv2Cbor`` protocol MUST be sent to a URL with the +following form: ``{prefix?}/service/{serviceName}/operation/{operationName}`` + +* The Smithy RPCv2 CBOR protocol will only use the last four segments of the + URL when routing requests. For example, a service could use a ``v1`` prefix + in the URL path, which would not affect the operation a request is routed + to: ``v1/service/FooService/operation/BarOperation`` +* The ``serviceName`` segment MUST be replaced by the :token:`shape name ` + of the service's :ref:`shape-id` in the Smithy model. The ``serviceName`` + produced by client implementations MUST NOT contain the namespace of the + ``service`` shape. Service implementations SHOULD accept an absolute shape + ID as the content of this segment with the ``#`` character replaced with a + ``.`` character, routing it the same as if only the name was specified. For + example, if the ``service``'s absolute shape ID is + ``com.example#TheService``, a service should accept both ``TheService`` and + ``com.example.TheService`` as values for the ``serviceName`` segment. +* The ``operationName`` segment MUST be replaced by the name of the ``operation`` + shape in the Smithy. The ``operationName`` produced by client + implementations MUST NOT contain the namespace of the ``operation`` shape. + Service implementations MUST NOT accept an absolute shape ID as the content + of this segment. + +Requests for the ``rpcv2Cbor`` protocol MUST use the following behavior for +setting a ``Content-Type`` header: + +* Buffered RPC requests: the value of the ``Content-Type`` header MUST be + ``application/cbor``. +* Event streaming requests: the value of the ``Content-Type`` header MUST be + ``application/vnd.amazon.eventstream``. +* Requests for operations with no defined input type (as in, they target the + ``Unit`` shape) MUST NOT contain bodies in their HTTP requests. The + ``Content-Type`` for the serialization format MUST NOT be set. + +Requests for the ``rpcv2Cbor`` protocol MUST NOT contain an ``X-Amz-Target`` or +``X-Amzn-Target`` header. An ``rpcv2Cbor`` request is malformed if it contains +either of these headers. Server-side implementations MUST reject such requests +for security reasons. + +Buffered RPC requests for the ``rpcv2Cbor`` protocol SHOULD include a +``Content-Length`` header. Event streaming requests MUST NOT specify a content +length (instead using ``Transfer-Encoding: chunked`` on HTTP/1.1). + +Event streaming requests for the ``rpcv2Cbor`` protocol MUST include an +``Accept`` header set to the value ``application/vnd.amazon.eventstream``. +Other forms of content streaming MAY be added in the future, utilizing +different values for ``Accept``. + +In summary, the ``rpcv2Cbor`` protocol defines behavior for the following +headers for requests: + +.. list-table:: + :header-rows: 1 + :widths: 18 18 64 + + * - Header + - Status + - Description + * - ``Smithy-Protocol`` + - Required + - The value of ``rpc-v2-cbor``. + * - ``Content-Type`` + - Required with request bodies + - The value of ``application/cbor``. For event streaming requests, this + is ``application/vnd.amazon.eventstream``. + * - ``Content-Length`` + - Conditional + - The standard ``Content-Length`` header defined by :rfc:`7230#section-3.3.2`. + For event streaming requests, this MUST NOT be set. + * - ``Accept`` + - Conditional + - For event streaming requests, to the value ``application/vnd.amazon.eventstream``. + + +~~~~~~~~~ +Responses +~~~~~~~~~ + +The status code for successful ``rpcv2Cbor`` responses MUST be ``200``. + +The status code for error ``rpcv2Cbor`` MUST be determined by the following +steps: + +1. If the :ref:`httpError ` trait is set on the error shape, + its value is used. +2. If the :ref:`error ` trait is set to ``server``, the value + MUST be ``500``. +3. Otherwise, the value MUST be ``400``. + +Every response for the ``rpcv2Cbor`` protocol MUST contain a ``Smithy-Protocol`` +header with the value of ``rpc-v2-cbor``. The response MUST match the value of +the ``Smithy-Protocol`` header from the request. + +Responses for the ``rpcv2Cbor`` protocol MUST use the following behavior for +setting a ``Content-Type`` header: + +* Buffered RPC responses: the value of the ``Content-Type`` header MUST be + ``application/cbor``. +* Event streaming responses: the value of the ``Content-Type`` header MUST be + ``application/vnd.amazon.eventstream``. +* Responses for operations with no defined output type (as in, they target the + ``Unit`` shape) MUST NOT contain bodies in their HTTP responses. The + ``Content-Type`` for the serialization format MUST NOT be set. + +Buffered RPC responses for the ``rpcv2Cbor`` protocol SHOULD include a +``Content-Length`` header. Event streaming responses SHOULD NOT specify a +content length (instead using ``Transfer-Encoding: chunked`` on HTTP/1.1). + +Responses for the ``rpcv2Cbor`` protocol SHOULD NOT contain the +``X-Amzn-ErrorType`` header. Type information is always serialized in the +payload. Clients MUST ignore this header. See `Operation error serialization`_ +for information on the serialization of error responses. + +In summary, the ``rpcv2Cbor`` protocol defines behavior for the following +headers for responses: + +.. list-table:: + :header-rows: 1 + :widths: 18 18 64 + + * - Header + - Status + - Description + * - ``Smithy-Protocol`` + - Required + - The value of ``rpc-v2-cbor``. + * - ``Content-Type`` + - Required with request bodies + - The value of ``application/cbor``. For event streaming requests, this + is ``application/vnd.amazon.eventstream``. + * - ``Content-Length`` + - Conditional + - The standard ``Content-Length`` header defined by :rfc:`7230#section-3.3.2`. + For event streaming requests, this SHOULD NOT be set. + + +------------------- +Shape serialization +------------------- + +The ``smithy.protocols#rpcv2Cbor`` protocol serializes all shapes into a CBOR +document body with no HTTP bindings supported. The following table shows how +to convert each shape type: + +.. list-table:: + :header-rows: 1 + :widths: 25 75 + + * - Smithy type + - CBOR representation + * - ``blob`` + - :rfc:`Major type 2 (byte string) <8949#section-3.1-2.5>` + * - ``boolean`` + - :rfc:`Major type 7 (simple) <8949#section-3.1-2.15>` + * - ``byte`` + - :rfc:`Major type 0 (unsigned integer) <8949#section-3.1-2.1>` or + :rfc:`major type 1 (negative integer) <8949#section-3.1-2.3>` + * - ``short`` + - :rfc:`Major type 0 (unsigned integer) <8949#section-3.1-2.1>` or + :rfc:`major type 1 (negative integer) <8949#section-3.1-2.3>` + * - ``integer`` + - :rfc:`Major type 0 (unsigned integer) <8949#section-3.1-2.1>` or + :rfc:`major type 1 (negative integer) <8949#section-3.1-2.3>` + * - ``long`` + - :rfc:`Major type 0 (unsigned integer) <8949#section-3.1-2.1>` or + :rfc:`major type 1 (negative integer) <8949#section-3.1-2.3>` + * - ``float`` + - :rfc:`Major type 7 (float) <8949#section-3.1-2.15>` + * - ``double`` + - :rfc:`Major type 7 (float) <8949#section-3.1-2.15>` + * - ``bigDecimal`` + - :rfc:`Major type 6 <8949#section-3.1-2.13>`, value + :rfc:`tags 2 (unsigned bignum) or 3 (negative bignum) <8949#section-3.4>` + * - ``bigInteger`` + - :rfc:`Major type 6 <8949#section-3.1-2.13>`, value + :rfc:`tag 4 (decimal fraction) <8949#section-3.4>` + * - ``string`` + - :rfc:`Major type 3 (text string) <8949#section-3.1-2.7>` + * - ``timestamp`` + - See `Timestamp type serialization`_. + * - ``document`` + - Document types are not currently supported in this protocol. + * - ``list`` + - :rfc:`Major type 4 (array of data items) <8949#section-3.1-2.9>` + * - ``map`` + - :rfc:`Major type 5 (map of pairs of data items) <8949#section-3.1-2.11>`, + each key/value pair is a pair in the type + * - ``structure`` + - :rfc:`Major type 5 (map of pairs of data items) <8949#section-3.1-2.11>`, + each member is the key to a pair in the type + * - ``union`` + - :rfc:`Major type 5 (map of pairs of data items) <8949#section-3.1-2.11>`, + each member is the key to a pair in the type. + + A union is serialized identically as a ``structure`` + shape, but only a single member can be set to a non-null value. + Deserializers MUST ignore an unrecognized ``__type`` member if present. + +Values that are ``null`` MUST be omitted from wire contents where not subject +to `default value serialization`_ rules. + +If an implementation does not support arbitrary precision (``bigInteger`` and +``bigDecimal`` Smithy types), it MUST fail when attempting to deserialize a +value of that type. + +.. note:: + The ``undefined`` CBOR value, CBOR :rfc:`major type 7 <8949#section-3.1-2.15>` + :rfc:`value 23 <8949#section-3.3>`, is not supported. Clients SHOULD NOT + serialize to this CBOR value and SHOULD deserialize this CBOR value to + ``null``. Servers MUST NOT serialize to this CBOR value and MUST + deserialize this CBOR value to ``null``. + +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Numeric type serialization +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Numeric types (``byte``, ``short``, ``integer``, ``long``, ``float``, and ``double``) +SHOULD be serialized into the smallest possible CBOR type representation that +can contain its value. For example, a field modeled as a ``long`` with a value of +1 should be sent in a single byte. + +Floating-point numeric types (``float`` and ``double``) MAY be serialized into +non-floating-point numeric types (``byte``, ``short``, ``integer``, and ``long``) if +and only if the conversion would not cause a loss of precision. For example, a +field modeled as a ``float`` with a value of 256 may be sent as an integer. + +As support for half-precision floating-point values is inconsistent across +implementations, floating-point numeric types SHOULD NOT serialize into a +half-precision (16 bit) numeric CBOR values. Implementations MUST be capable of +deserializing half-precision numeric CBOR values (including -Infinity, +Infinity, and NAN) into their Smithy type representation. + +Numeric types MUST be deserialized into their Smithy type representation. For +example, a field modeled as a ``long`` with a single byte value of 1 must be +deserialized into a long. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Timestamp type serialization +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Timestamps are serialized as :rfc:`major type 6 <8949#section-3.1-2.13>`, value +:rfc:`tag 1 (epoch-based date/time) <8949#section-3.4>` to indicate the tagged +value is an epoch timestamp. Values are either :rfc:`major type 0 (unsigned integer) <8949#section-3.1-2.1>` +or :rfc:`major type 1 (negative integer) <8949#section-3.1-2.3>` for integer +values or :rfc:`major type 7 <8949#section-3.1-2.15>`, +:rfc:`value 25 (half-precision float), 26 (single-precision float), or 27 (double-precision float) <8949#section-3.3>` +for floating-point values. + +As support for half-precision floating-point values is inconsistent across +implementations, timestamp types SHOULD NOT serialize into a half-precision +(16 bit) numeric CBOR value for the tagged value. + +This protocol uses ``epoch-seconds``, also known as Unix timestamps, with +millisecond (1/1000th of a second) resolution. The :ref:`timestampFormat ` +MUST NOT be respected to customize timestamp serialization. + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Default value serialization +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To avoid information disclosure, service serializers SHOULD omit the default +value of structure members that are marked with the :ref:`internal trait `. + +Client deserializers SHOULD attempt to error correct structures that omit a +:ref:`required ` member by filling in a default zero value for +the member. Error correction allows clients to continue to function while the +server is in error. + +---------------------------------- +Operation response deserialization +---------------------------------- + +Clients MUST use the following rules to interpret responses and determine how +to deserialize them: + +1. If the response does not have the same ``Smithy-Protocol`` header as the + request, it MUST be considered malformed. Clients who receive a malformed + response MUST handle it (i.e. throw a reasonable exception) based solely on + the HTTP response code. No attempt should be made to interpret the response + body or headers. +2. If the response code is ``200``, the request is successful and the response + payload SHALL be deserialized as the ``output`` shape defined on the + operation. +3. Finally, if the response code is not ``200``, the response payload is an + exception and SHALL be deserialized according to `Operation error serialization`_ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Operation error serialization +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Error responses in the ``rpcv2Cbor`` protocol MUST be serialized identically to +standard responses with one additional component to distinguish which error is +contained: a body field named ``__type``. This value of this component MUST +contain the error’s absolute :ref:`shape-id`. + +By default, all error shapes have a ``message`` field containing an +error-specific message meant for human consumers of API errors. Services MUST +support generating this field and serializing it when responding. Clients MUST +support generating this field and deserializing it from responses. + +The ``Code`` response body field and ``code`` response body field MUST NOT be +used to distinguish which error is contained in a response. + +Clients who receive a malformed error response MUST handle it based solely on +the HTTP response code (i.e. throw a reasonable exception). No attempt should +be made to interpret the response body or headers. + +.. include:: ../../aws/protocols/error-rename-simple.rst.template + +.. _`Application-Layer Protocol Negotiation (ALPN) Protocol ID`: https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids diff --git a/docs/source-2.0/aws/protocols/aws-query-protocol.rst b/docs/source-2.0/aws/protocols/aws-query-protocol.rst index 2ccc4574ce3..b917034423a 100644 --- a/docs/source-2.0/aws/protocols/aws-query-protocol.rst +++ b/docs/source-2.0/aws/protocols/aws-query-protocol.rst @@ -549,19 +549,20 @@ The following example defines an error that uses a custom "Code" of Summary When using the :ref:`awsQuery ` protocol, - custom ``Code`` and ``HTTP response code`` values can be defined for an error response via - the :ref:`awsQueryError ` trait. - - The ``awsQueryCompatible`` trait allows services to backward compatibly migrate from ``awsQuery`` to - :ref:`awsJson1_0 ` without removing values defined in the ``awsQueryError`` trait. - - This trait adds the ``x-amzn-query-error`` header in the form of ``Code;Fault`` to error responses. - ``Code`` is the value defined in the :ref:`awsQueryError `, - and ``Fault`` is one of ``Sender`` or ``Receiver``. - + custom ``Code`` and ``HTTP response code`` values can be defined for an + error response via the :ref:`awsQueryError ` + trait. + + The ``awsQueryCompatible`` trait allows services to backward compatibly + migrate from ``awsQuery`` to :ref:`awsJson1_0 ` + without removing values defined in the ``awsQueryError`` trait. + + This trait adds the ``x-amzn-query-error`` header in the form of + ``Code;Fault`` to error responses. ``Code`` is the value defined in the + :ref:`awsQueryError `, and ``Fault`` is + one of ``Sender`` or ``Receiver``. Trait selector ``service [trait|awsJson1_0]`` - Value type Annotation trait @@ -587,6 +588,11 @@ Value type message: String } +.. important:: + + AWS client implementations of the ``smithy.protocols#rpcv2Cbor`` protocol + MUST support the ``aws.protocols#awsQueryCompatible`` trait. + .. _awsQuery-compliance-tests: From 14e6eabcd6997ada082e115bba46ea2ac2fa6f99 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Wed, 13 Mar 2024 08:45:16 -0700 Subject: [PATCH 09/30] Add no document types validation to rpcv2Cbor --- .../amazon/smithy/model/loader/prelude.smithy | 3 ++- .../smithy/smithy.protocols.rpcv2.smithy | 6 ++++++ .../errorfiles/no-document-support.errors | 1 + .../errorfiles/no-document-support.smithy | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors create mode 100644 smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy diff --git a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy index 0c526122766..f4cc38035ea 100644 --- a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy +++ b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy @@ -309,6 +309,7 @@ structure httpApiKeyAuth { /// /// `traitValidators` is a map of validation event IDs to validators to apply to a shape. /// Selectors are used to identify shapes that are incompatible with a constrained trait. +/// The shape with the targeted trait applied MUST be a valid entry point for the selector. /// /// The following example defines a protocol that does not support document types. Each matching member found in the /// closure of an attached shape emits a validation event: @@ -317,7 +318,7 @@ structure httpApiKeyAuth { /// @trait(selector: "service") /// @traitValidators( /// "myCustomProtocol.NoDocuments": { -/// selector: "member :test(> document)" +/// selector: "~> member :test(> document)" /// message: "This protocol does not support document types" /// } /// ) diff --git a/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy index 8fb2d37e5cc..68c672b7b27 100644 --- a/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy +++ b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy @@ -15,6 +15,12 @@ use smithy.api#httpError hostLabel httpError ]) +@traitValidators( + "rpcv2Cbor.NoDocuments": { + selector: "service ~> member :test(> document)" + message: "This protocol does not support document types" + } +) structure rpcv2Cbor { /// Priority ordered list of supported HTTP protocol versions. http: StringList diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors new file mode 100644 index 00000000000..1062699e1ef --- /dev/null +++ b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors @@ -0,0 +1 @@ +[ERROR] smithy.example#DocumentOperationInput$document: Found an incompatible shape when validating the constraints of the `smithy.protocols#rpcv2Cbor` trait attached to `smithy.example#DocumentService`: This protocol does not support document types | rpcv2Cbor.NoDocuments diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy new file mode 100644 index 00000000000..10ed73af30b --- /dev/null +++ b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy @@ -0,0 +1,19 @@ +$version: "2.0" + +namespace smithy.example + +use smithy.protocols#rpcv2Cbor + +@rpcv2Cbor +service DocumentService { + version: "2023-02-10" + operations: [ + DocumentOperation + ] +} + +operation DocumentOperation { + input := { + document: Document + } +} From 8de980aff175e8f1bb632653c438927101e45a56 Mon Sep 17 00:00:00 2001 From: Adwait Kumar Singh Date: Fri, 4 Aug 2023 12:14:00 -0700 Subject: [PATCH 10/30] Basic protocol tests --- smithy-aws-protocol-tests/build.gradle | 1 + .../model/rpcV2/cbor-lists.smithy | 258 ++++++++++++ .../model/rpcV2/cbor-maps.smithy | 393 ++++++++++++++++++ .../model/rpcV2/cbor-structs.smithy | 322 ++++++++++++++ .../model/rpcV2/empty-input-output.smithy | 187 +++++++++ .../model/rpcV2/errors.smithy | 93 +++++ .../model/rpcV2/fractional-seconds.smithy | 30 ++ .../model/rpcV2/main.smithy | 33 ++ .../model/shared-types.smithy | 35 +- 9 files changed, 1349 insertions(+), 3 deletions(-) create mode 100644 smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/errors.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy create mode 100644 smithy-aws-protocol-tests/model/rpcV2/main.smithy diff --git a/smithy-aws-protocol-tests/build.gradle b/smithy-aws-protocol-tests/build.gradle index 2a4b95bb3ab..279f4b8a122 100644 --- a/smithy-aws-protocol-tests/build.gradle +++ b/smithy-aws-protocol-tests/build.gradle @@ -27,6 +27,7 @@ ext { dependencies { implementation project(path: ":smithy-cli", configuration: "shadow") implementation project(":smithy-protocol-test-traits") + implementation project(":smithy-protocol-traits") implementation project(":smithy-aws-traits") api project(":smithy-validation-model") } diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy new file mode 100644 index 00000000000..7fe2289db09 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy @@ -0,0 +1,258 @@ +// This file defines test cases that serialize lists in JSON documents. + +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use aws.protocoltests.shared#BooleanList +use aws.protocoltests.shared#FooEnumList +use aws.protocoltests.shared#IntegerEnumList +use aws.protocoltests.shared#IntegerList +use aws.protocoltests.shared#NestedStringList +use aws.protocoltests.shared#SparseStringList +use aws.protocoltests.shared#StringList +use aws.protocoltests.shared#StringSet +use aws.protocoltests.shared#TimestampList +use smithy.protocols#rpcv2Cbor +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + +/// This test case serializes JSON lists for the following cases for both +/// input and output: +/// +/// 1. Normal lists. +/// 2. Normal sets. +/// 3. Lists of lists. +/// 4. Lists of structures. +@idempotent +operation RpcV2CborLists { + input: RpcV2CborListInputOutput, + output: RpcV2CborListInputOutput +} + +apply RpcV2CborLists @httpRequestTests([ + { + id: "RpcV2CborLists", + documentation: "Serializes RpcV2 Cbor lists", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "v2tib29sZWFuTGlzdJ/19P9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9raW50ZWdlckxpc3SfAQL/cG5lc3RlZFN0cmluZ0xpc3Sfn2Nmb29jYmFy/59jYmF6Y3F1eP//anN0cmluZ0xpc3SfY2Zvb2NiYXL/aXN0cmluZ1NldJ9jZm9vY2Jhcv9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP//", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "stringList": [ + "foo", + "bar" + ], + "stringSet": [ + "foo", + "bar" + ], + "integerList": [ + 1, + 2 + ], + "booleanList": [ + true, + false + ], + "timestampList": [ + 1398796238, + 1398796238 + ], + "enumList": [ + "Foo", + "0" + ], + "intEnumList": [ + 1, + 2 + ], + "nestedStringList": [ + [ + "foo", + "bar" + ], + [ + "baz", + "qux" + ] + ], + "structureList": [ + { + "a": "1", + "b": "2" + }, + { + "a": "3", + "b": "4" + } + ] + } + }, + { + id: "RpcV2CborListsEmpty", + documentation: "Serializes empty JSON lists", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "v2pzdHJpbmdMaXN0n///", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + stringList: [] + } + }, + { + id: "RpcV2CborListsSerializeNull", + documentation: "Serializes null values in lists", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "v3BzcGFyc2VTdHJpbmdMaXN0n/ZiaGn//w==", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + sparseStringList: [null, "hi"] + } + } +]) + +apply RpcV2CborLists @httpResponseTests([ + { + id: "RpcV2CborLists", + documentation: "Serializes RpcV2 Cbor lists", + protocol: rpcv2Cbor, + code: 200, + body: "v2tib29sZWFuTGlzdJ/19P9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9raW50ZWdlckxpc3SfAQL/cG5lc3RlZFN0cmluZ0xpc3Sfn2Nmb29jYmFy/59jYmF6Y3F1eP//anN0cmluZ0xpc3SfY2Zvb2NiYXL/aXN0cmluZ1NldJ9jZm9vY2Jhcv9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP//", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "stringList": [ + "foo", + "bar" + ], + "stringSet": [ + "foo", + "bar" + ], + "integerList": [ + 1, + 2 + ], + "booleanList": [ + true, + false + ], + "timestampList": [ + 1398796238, + 1398796238 + ], + "enumList": [ + "Foo", + "0" + ], + "intEnumList": [ + 1, + 2 + ], + "nestedStringList": [ + [ + "foo", + "bar" + ], + [ + "baz", + "qux" + ] + ], + "structureList": [ + { + "a": "1", + "b": "2" + }, + { + "a": "3", + "b": "4" + } + ] + } + }, + { + id: "RpcV2CborListsEmpty", + documentation: "Serializes empty RpcV2 Cbor lists", + protocol: rpcv2Cbor, + code: 200, + body: "v2pzdHJpbmdMaXN0n///", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + stringList: [] + } + }, + { + id: "RpcV2CborListsSerializeNull", + documentation: "Serializes null values in sparse lists", + protocol: rpcv2Cbor, + code: 200, + body: "v3BzcGFyc2VTdHJpbmdMaXN0n/ZiaGn//w==", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + sparseStringList: [null, "hi"] + } + } +]) + +structure RpcV2CborListInputOutput { + stringList: StringList, + + sparseStringList: SparseStringList, + + stringSet: StringSet, + + integerList: IntegerList, + + booleanList: BooleanList, + + timestampList: TimestampList, + + enumList: FooEnumList, + + intEnumList: IntegerEnumList, + + nestedStringList: NestedStringList, + + structureList: StructureList +} + +list StructureList { + member: StructureListMember, +} + +structure StructureListMember { + a: String, + b: String, +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy new file mode 100644 index 00000000000..2dabe26eb3d --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -0,0 +1,393 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use aws.protocoltests.shared#FooEnumMap +use aws.protocoltests.shared#GreetingStruct +use aws.protocoltests.shared#SparseStringMap +use aws.protocoltests.shared#StringSet +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests +use smithy.protocols#rpcv2Cbor + +/// The example tests basic map serialization. +operation RpcV2CborMaps { + input: RpcV2CborMapsInputOutput, + output: RpcV2CborMapsInputOutput +} + +apply RpcV2CborMaps @httpRequestTests([ + { + id: "RpcV2CborMaps", + documentation: "Serializes maps", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v25kZW5zZVN0cnVjdE1hcL9jYmF6v2JoaWNieWX/Y2Zvb79iaGlldGhlcmX//29zcGFyc2VTdHJ1Y3RNYXC/Y2Jher9iaGljYnll/2Nmb2+/YmhpZXRoZXJl////", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } + }, + "sparseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } + } + } + }, + { + id: "RpcV2CborSerializesNullMapValues", + documentation: "Serializes map values in sparse maps", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseBooleanMap": { + "x": null + }, + "sparseNumberMap": { + "x": null + }, + "sparseStringMap": { + "x": null + }, + "sparseStructMap": { + "x": null + } + } + }, + { + id: "RpcV2CborSerializesZeroValuesInMaps", + documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v29kZW5zZUJvb2xlYW5NYXC/YXj0/25kZW5zZU51bWJlck1hcL9heAD/cHNwYXJzZUJvb2xlYW5NYXC/YXj0/29zcGFyc2VOdW1iZXJNYXC/YXgA//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseNumberMap": { + "x": 0 + }, + "sparseNumberMap": { + "x": 0 + }, + "denseBooleanMap": { + "x": false + }, + "sparseBooleanMap": { + "x": false + } + } + }, + { + id: "RpcV2CborSerializesSparseSetMap", + documentation: "A request that contains a sparse map of sets", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + }, + { + id: "RpcV2CborSerializesDenseSetMap", + documentation: "A request that contains a dense map of sets.", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + }, + { + id: "RpcV2CborSerializesSparseSetMapAndRetainsNull", + documentation: "A request that contains a sparse map of sets.", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", + body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"], + "z": null + } + } + } +]) + +apply RpcV2CborMaps @httpResponseTests([ + { + id: "RpcV2CborMaps", + documentation: "Deserializes maps", + protocol: rpcv2Cbor, + code: 200, + body: "v25kZW5zZVN0cnVjdE1hcL9jYmF6v2JoaWNieWX/Y2Zvb79iaGlldGhlcmX//29zcGFyc2VTdHJ1Y3RNYXC/Y2Jher9iaGljYnll/2Nmb2+/YmhpZXRoZXJl////", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } + }, + "sparseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } + } + } + }, + { + id: "RpcV2CborDeserializesNullMapValues", + documentation: "Deserializes null map values", + protocol: rpcv2Cbor, + code: 200, + body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseBooleanMap": { + "x": null + }, + "sparseNumberMap": { + "x": null + }, + "sparseStringMap": { + "x": null + }, + "sparseStructMap": { + "x": null + } + } + }, + { + id: "RpcV2CborDeserializesZeroValuesInMaps", + documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", + protocol: rpcv2Cbor, + code: 200, + body: "v29kZW5zZUJvb2xlYW5NYXC/YXj0/25kZW5zZU51bWJlck1hcL9heAD/cHNwYXJzZUJvb2xlYW5NYXC/YXj0/29zcGFyc2VOdW1iZXJNYXC/YXgA//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseNumberMap": { + "x": 0 + }, + "sparseNumberMap": { + "x": 0 + }, + "denseBooleanMap": { + "x": false + }, + "sparseBooleanMap": { + "x": false + } + } + }, + { + id: "RpcV2CborDeserializesSparseSetMap", + documentation: "A response that contains a sparse map of sets", + protocol: rpcv2Cbor, + code: 200, + body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + }, + { + id: "RpcV2CborDeserializesDenseSetMap", + documentation: "A response that contains a dense map of sets.", + protocol: rpcv2Cbor, + code: 200, + body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + }, + { + id: "RpcV2CborDeserializesSparseSetMapAndRetainsNull", + documentation: "A response that contains a sparse map of sets.", + protocol: rpcv2Cbor, + code: 200, + body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"], + "z": null + } + } + }, + { + id: "RpcV2CborDeserializesDenseSetMapAndSkipsNull", + documentation: """ + Clients SHOULD tolerate seeing a null value in a dense map, and they SHOULD + drop the null key-value pair.""", + protocol: rpcv2Cbor, + appliesTo: "client", + code: 200, + body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + } +]) + +structure RpcV2CborMapsInputOutput { + denseStructMap: DenseStructMap, + sparseStructMap: SparseStructMap, + denseNumberMap: DenseNumberMap, + denseBooleanMap: DenseBooleanMap, + denseStringMap: DenseStringMap, + sparseNumberMap: SparseNumberMap, + sparseBooleanMap: SparseBooleanMap, + sparseStringMap: SparseStringMap, + denseSetMap: DenseSetMap, + sparseSetMap: SparseSetMap, +} + +map DenseStructMap { + key: String, + value: GreetingStruct +} + +@sparse +map SparseStructMap { + key: String, + value: GreetingStruct +} + +map DenseBooleanMap { + key: String, + value: Boolean +} + +map DenseNumberMap { + key: String, + value: Integer +} + +map DenseStringMap { + key: String, + value: String +} + +@sparse +map SparseBooleanMap { + key: String, + value: Boolean +} + +@sparse +map SparseNumberMap { + key: String, + value: Integer +} + +map DenseSetMap { + key: String, + value: StringSet +} + +@sparse +map SparseSetMap { + key: String, + value: StringSet +} + diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy new file mode 100644 index 00000000000..b359d73c1c5 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -0,0 +1,322 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use smithy.protocols#rpcv2Cbor +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + + +@httpRequestTests([ + { + id: "RpcV2CborSimpleScalarProperties", + protocol: rpcv2Cbor, + 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.rpcv2Cbor.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: rpcv2Cbor, + method: "POST", + uri: "/service/aws.protocoltests.rpcv2Cbor.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: rpcv2Cbor, + method: "POST", + uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tzdHJpbmdWYWx1Zfb/", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + params: {}, + appliesTo: "server" + }, + { + id: "RpcV2CborSupportsNaNFloatInputs", + protocol: rpcv2Cbor, + documentation: "Supports handling NaN float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/" + params: { + doubleValue: "NaN", + floatValue: "NaN" + } + }, + { + id: "RpcV2CborSupportsInfinityFloatInputs", + protocol: rpcv2Cbor, + documentation: "Supports handling Infinity float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/" + params: { + doubleValue: "Infinity", + floatValue: "Infinity" + } + }, + { + id: "RpcV2CborSupportsNegativeInfinityFloatInputs", + protocol: rpcv2Cbor, + documentation: "Supports handling Infinity float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/" + params: { + doubleValue: "-Infinity", + floatValue: "-Infinity" + } + } +]) +@httpResponseTests([ + { + id: "RpcV2CborSimpleScalarProperties", + protocol: rpcv2Cbor, + 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: rpcv2Cbor, + 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: rpcv2Cbor, + body: "v/8=", + code: 200, + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + params: { + stringValue: null + }, + appliesTo: "server" + }, + { + id: "RpcV2CborSupportsNaNFloatOutputs", + protocol: rpcv2Cbor, + documentation: "Supports handling NaN float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + code: 200, + bodyMediaType: "application/cbor", + body: "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/" + params: { + doubleValue: "NaN", + floatValue: "NaN" + } + }, + { + id: "RpcV2CborSupportsInfinityFloatOutputs", + protocol: rpcv2Cbor, + documentation: "Supports handling Infinity float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + code: 200, + bodyMediaType: "application/cbor", + body: "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/" + params: { + doubleValue: "Infinity", + floatValue: "Infinity" + } + }, + { + id: "RpcV2CborSupportsNegativeInfinityFloatOutputs", + protocol: rpcv2Cbor, + documentation: "Supports handling Negative Infinity float values.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + code: 200, + bodyMediaType: "application/cbor", + body: "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/" + params: { + doubleValue: "-Infinity", + floatValue: "-Infinity" + } + } +]) +operation SimpleScalarProperties { + input: SimpleScalarStructure, + output: SimpleScalarStructure +} + +apply RecursiveShapes @httpRequestTests([ + { + id: "RpcV2CborRecursiveShapes", + documentation: "Serializes recursive structures", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RecursiveShapes", + body: "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + nested: { + foo: "Foo1", + nested: { + bar: "Bar1", + recursiveMember: { + foo: "Foo2", + nested: { + bar: "Bar2" + } + } + } + } + } + } +]) + +apply RecursiveShapes @httpResponseTests([ + { + id: "RpcV2CborRecursiveShapes", + documentation: "Serializes recursive structures", + protocol: rpcv2Cbor, + code: 200, + body: "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + nested: { + foo: "Foo1", + nested: { + bar: "Bar1", + recursiveMember: { + foo: "Foo2", + nested: { + bar: "Bar2" + } + } + } + } + } + } +]) + +operation RecursiveShapes { + input: RecursiveShapesInputOutput, + output: RecursiveShapesInputOutput +} + +structure RecursiveShapesInputOutput { + nested: RecursiveShapesInputOutputNested1 +} + +structure RecursiveShapesInputOutputNested1 { + foo: String, + nested: RecursiveShapesInputOutputNested2 +} + +structure RecursiveShapesInputOutputNested2 { + bar: String, + recursiveMember: RecursiveShapesInputOutputNested1, +} + + +structure SimpleScalarStructure { + trueBooleanValue: Boolean, + falseBooleanValue: Boolean, + byteValue: Byte, + doubleValue: Double, + floatValue: Float, + integerValue: Integer, + longValue: Long, + shortValue: Short, + stringValue: String, +} \ No newline at end of file diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy new file mode 100644 index 00000000000..1a03e77919e --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy @@ -0,0 +1,187 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use smithy.protocols#rpcv2Cbor +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + + +@httpRequestTests([ + { + id: "no_input", + protocol: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + body: "" + }, + { + id: "no_input_server_allows_accept", + protocol: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + body: "", + appliesTo: "server" + }, + { + id: "no_input_server_allows_empty_cbor", + protocol: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + body: "v/8=", + appliesTo: "server" + }, + { + id: "NoInputServerIngoresUnexpectedFields", + protocol: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + body: "v/8=", + appliesTo: "server" + } +]) +@httpResponseTests([ + { + id: "no_output", + protocol: rpcv2Cbor, + 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: rpcv2Cbor, + 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: rpcv2Cbor, + 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: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/EmptyInputOutput", + body: "v/8=", + }, +]) +@httpResponseTests([ + { + id: "empty_output", + protocol: rpcv2Cbor, + 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: rpcv2Cbor, + 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.rpcv2Cbor.RpcV2Protocol/operation/OptionalInputOutput", + body: "v/8=", + }, +]) +@httpResponseTests([ + { + id: "optional_output", + protocol: rpcv2Cbor, + 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 +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/errors.smithy b/smithy-aws-protocol-tests/model/rpcV2/errors.smithy new file mode 100644 index 00000000000..5010cfa50ef --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/errors.smithy @@ -0,0 +1,93 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests +use smithy.protocols#rpcv2Cbor + +/// This operation has three possible return values: +/// +/// 1. A successful response in the form of GreetingWithErrorsOutput +/// 2. An InvalidGreeting error. +/// 3. A ComplexError error. +/// +/// Implementations must be able to successfully take a response and +/// properly deserialize successful and error responses. +@idempotent +operation GreetingWithErrors { + output: GreetingWithErrorsOutput, + errors: [InvalidGreeting, ComplexError] +} + +structure GreetingWithErrorsOutput { + greeting: String, +} + +/// This error is thrown when an invalid greeting value is provided. +@error("client") +structure InvalidGreeting { + Message: String, +} + +apply InvalidGreeting @httpResponseTests([ + { + id: "RpcV2CborInvalidGreetingError", + documentation: "Parses simple RpcV2 Cbor errors", + protocol: rpcv2Cbor, + params: { + Message: "Hi" + }, + code: 400, + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + body: "v2ZfX3R5cGV4J2F3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0ludmFsaWRHcmVldGluZ2dNZXNzYWdlYkhp/w==", + bodyMediaType: "application/cbor", + }, +]) + +/// This error is thrown when a request is invalid. +@error("client") +structure ComplexError { + TopLevel: String, + Nested: ComplexNestedErrorData, +} + +structure ComplexNestedErrorData { + Foo: String, +} + +apply ComplexError @httpResponseTests([ + { + id: "RpcV2CborComplexError", + documentation: "Parses a complex error with no message member", + protocol: rpcv2Cbor, + params: { + TopLevel: "Top level", + Nested: { + Foo: "bar" + } + }, + code: 400, + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + body: "v2ZfX3R5cGV4JGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0NvbXBsZXhFcnJvcmZOZXN0ZWS/Y0Zvb2NiYXL/aFRvcExldmVsaVRvcCBsZXZlbP8=", + bodyMediaType: "application/cbor" + }, + { + id: "RpcV2CborEmptyComplexError", + protocol: rpcv2Cbor, + code: 400, + headers: { + "Content-Type": "application/x-amz-json-1.1" + }, + body: "v2ZfX3R5cGV4JGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0NvbXBsZXhFcnJvcv8=", + bodyMediaType: "application/cbor" + }, +]) + + diff --git a/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy b/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy new file mode 100644 index 00000000000..8be731e963e --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy @@ -0,0 +1,30 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use smithy.protocols#rpcv2Cbor +use aws.protocoltests.shared#DateTime +use smithy.test#httpResponseTests + +// These tests verify that clients can parse `DateTime` timestamps with fractional seconds. +@tags(["client-only"]) +operation FractionalSeconds { + output: FractionalSecondsOutput +} + +apply FractionalSeconds @httpResponseTests([ + { + id: "RpcV2CborDateTimeWithFractionalSeconds", + documentation: "Ensures that clients can correctly parse timestamps with fractional seconds", + protocol: rpcv2Cbor, + code: 200, + body: "v2hkYXRldGltZcH7Qcw32zgPvnf/", + params: { datetime: 946845296.123 } + bodyMediaType: "application/cbor", + appliesTo: "client" + } +]) + +structure FractionalSecondsOutput { + datetime: DateTime +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-aws-protocol-tests/model/rpcV2/main.smithy new file mode 100644 index 00000000000..1ea3dfa683d --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/main.smithy @@ -0,0 +1,33 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor +use aws.api#service +use smithy.protocols#rpcv2Cbor +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests + +@service(sdkId: "Sample RpcV2 Protocol") +@rpcv2Cbor +@title("RpcV2 Protocol Service") +service RpcV2Protocol { + version: "2020-07-14", + operations: [ + NoInputOutput, + EmptyInputOutput, + OptionalInputOutput, + SimpleScalarProperties, + RpcV2CborLists, + RpcV2CborMaps, + RecursiveShapes, + GreetingWithErrors, + FractionalSeconds + ] +} + +structure EmptyStructure { + +} + +structure SimpleStructure { + value: String, +} \ No newline at end of file diff --git a/smithy-aws-protocol-tests/model/shared-types.smithy b/smithy-aws-protocol-tests/model/shared-types.smithy index 4e88e464e81..9b282b22959 100644 --- a/smithy-aws-protocol-tests/model/shared-types.smithy +++ b/smithy-aws-protocol-tests/model/shared-types.smithy @@ -55,6 +55,10 @@ list NestedStringList { member: StringList, } +list ShortList { + member: Short, +} + list IntegerList { member: Integer, } @@ -64,6 +68,10 @@ list IntegerSet { member: Integer, } +list FloatList { + member: Float, +} + list DoubleList { member: Double, } @@ -81,11 +89,19 @@ list TimestampList { member: Timestamp, } +list BlobList { + member: Blob, +} + @uniqueItems list BlobSet { member: Blob, } +list ByteList { + member: Byte, +} + @uniqueItems list ByteSet { member: Byte, @@ -95,16 +111,29 @@ list ShortSet { member: Short, } +@uniqueItems +list LongList { + member: Long, +} + @uniqueItems list LongSet { member: Long, } +list TimestampList { + member: Timestamp, +} + @uniqueItems list TimestampSet { member: Timestamp, } +list DateTimeList { + member: DateTime, +} + @uniqueItems list DateTimeSet { member: DateTime, @@ -192,10 +221,10 @@ list IntegerEnumList { @uniqueItems list IntegerEnumSet { - member: IntegerEnum + member: IntegerEnum } map IntegerEnumMap { - key: String, - value: IntegerEnum + key: String, + value: IntegerEnum } From 302410c89def532be1fbecd9fd0fa725d6a3b578 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Wed, 13 Mar 2024 19:39:06 +0000 Subject: [PATCH 11/30] Fix the mismatch in the CBOR body from the parameters, add a default test, and add the missing headers --- .../model/rpcV2/cbor-lists.smithy | 55 +++++- .../model/rpcV2/cbor-maps.smithy | 27 +-- .../model/rpcV2/cbor-structs.smithy | 167 ++++++++++++++++-- .../model/rpcV2/empty-input-output.smithy | 14 +- .../model/rpcV2/errors.smithy | 11 +- .../model/rpcV2/fractional-seconds.smithy | 4 + .../model/rpcV2/main.smithy | 5 +- 7 files changed, 242 insertions(+), 41 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy index 7fe2289db09..d0df8cf5455 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy @@ -16,6 +16,7 @@ use aws.protocoltests.shared#TimestampList use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests use smithy.test#httpResponseTests +use smithy.framework#ValidationException /// This test case serializes JSON lists for the following cases for both /// input and output: @@ -27,7 +28,8 @@ use smithy.test#httpResponseTests @idempotent operation RpcV2CborLists { input: RpcV2CborListInputOutput, - output: RpcV2CborListInputOutput + output: RpcV2CborListInputOutput, + errors: [ValidationException] } apply RpcV2CborLists @httpRequestTests([ @@ -112,6 +114,23 @@ apply RpcV2CborLists @httpRequestTests([ stringList: [] } }, + { + id: "RpcV2CborListsEmptyUsingDefiniteLength", + documentation: "Serializes empty JSON definite length lists", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "oWpzdHJpbmdMaXN0gA==" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + stringList: [] + } + }, { id: "RpcV2CborListsSerializeNull", documentation: "Serializes null values in lists", @@ -128,6 +147,40 @@ apply RpcV2CborLists @httpRequestTests([ params: { sparseStringList: [null, "hi"] } + }, + { + id: "RpcV2CborSparseListWithIndefiniteString", + documentation: "Serializes indefinite length text strings inside an indefinite length list", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "v3BzcGFyc2VTdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + sparseStringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] + } + }, + { + id: "RpcV2CborListWithIndefiniteString", + documentation: "Serializes indefinite length text strings inside a definite length list", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + body: "oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + stringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] + } } ]) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy index 2dabe26eb3d..baf53dc7be1 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -9,11 +9,13 @@ use aws.protocoltests.shared#StringSet use smithy.test#httpRequestTests use smithy.test#httpResponseTests use smithy.protocols#rpcv2Cbor +use smithy.framework#ValidationException /// The example tests basic map serialization. operation RpcV2CborMaps { input: RpcV2CborMapsInputOutput, - output: RpcV2CborMapsInputOutput + output: RpcV2CborMapsInputOutput, + errors: [ValidationException] } apply RpcV2CborMaps @httpRequestTests([ @@ -23,7 +25,7 @@ apply RpcV2CborMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v25kZW5zZVN0cnVjdE1hcL9jYmF6v2JoaWNieWX/Y2Zvb79iaGlldGhlcmX//29zcGFyc2VTdHJ1Y3RNYXC/Y2Jher9iaGljYnll/2Nmb2+/YmhpZXRoZXJl////", + body: "v25kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZW9zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb6FiaGlldGhlcmVjYmF6oWJoaWNieWX//w==" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -55,7 +57,7 @@ apply RpcV2CborMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", + body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -83,7 +85,7 @@ apply RpcV2CborMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v29kZW5zZUJvb2xlYW5NYXC/YXj0/25kZW5zZU51bWJlck1hcL9heAD/cHNwYXJzZUJvb2xlYW5NYXC/YXj0/29zcGFyc2VOdW1iZXJNYXC/YXgA//8=", + body: "v25kZW5zZU51bWJlck1hcKFheABvc3BhcnNlTnVtYmVyTWFwv2F4AP9vZGVuc2VCb29sZWFuTWFwoWF49HBzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -111,7 +113,7 @@ apply RpcV2CborMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + body: "v2xzcGFyc2VTZXRNYXC/YXiAYXmCYWFhYv//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -131,7 +133,7 @@ apply RpcV2CborMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -174,7 +176,7 @@ apply RpcV2CborMaps @httpResponseTests([ documentation: "Deserializes maps", protocol: rpcv2Cbor, code: 200, - body: "v25kZW5zZVN0cnVjdE1hcL9jYmF6v2JoaWNieWX/Y2Zvb79iaGlldGhlcmX//29zcGFyc2VTdHJ1Y3RNYXC/Y2Jher9iaGljYnll/2Nmb2+/YmhpZXRoZXJl////", + body: "v25kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZW9zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb6FiaGlldGhlcmVjYmF6oWJoaWNieWX//w==" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -204,7 +206,7 @@ apply RpcV2CborMaps @httpResponseTests([ documentation: "Deserializes null map values", protocol: rpcv2Cbor, code: 200, - body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", + body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -230,7 +232,7 @@ apply RpcV2CborMaps @httpResponseTests([ documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, code: 200, - body: "v29kZW5zZUJvb2xlYW5NYXC/YXj0/25kZW5zZU51bWJlck1hcL9heAD/cHNwYXJzZUJvb2xlYW5NYXC/YXj0/29zcGFyc2VOdW1iZXJNYXC/YXgA//8=", + body: "v25kZW5zZU51bWJlck1hcKFheABvc3BhcnNlTnVtYmVyTWFwv2F4AP9vZGVuc2VCb29sZWFuTWFwoWF49HBzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -274,7 +276,7 @@ apply RpcV2CborMaps @httpResponseTests([ documentation: "A response that contains a dense map of sets.", protocol: rpcv2Cbor, code: 200, - body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -314,7 +316,7 @@ apply RpcV2CborMaps @httpResponseTests([ protocol: rpcv2Cbor, appliesTo: "client", code: 200, - body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + body: "oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -323,7 +325,8 @@ apply RpcV2CborMaps @httpResponseTests([ params: { "denseSetMap": { "x": [], - "y": ["a", "b"] + "y": ["a", "b"], + "z": null } } } diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index b359d73c1c5..b196557c016 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -6,7 +6,6 @@ use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests use smithy.test#httpResponseTests - @httpRequestTests([ { id: "RpcV2CborSimpleScalarProperties", @@ -19,26 +18,56 @@ use smithy.test#httpResponseTests } method: "POST", bodyMediaType: "application/cbor", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/SimpleScalarProperties", - body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=" + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==" params: { - trueBooleanValue: true, - falseBooleanValue: false, byteValue: 5, doubleValue: 1.889, + falseBooleanValue: false, floatValue: 7.624, integerValue: 256, - shortValue: 9898, longValue: 9873, - stringValue: "simple" + shortValue: 9898, + stringValue: "simple", + trueBooleanValue: true, + blobValue: "foo" } }, + { + id: "RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength", + protocol: rpcv2Cbor, + documentation: """ + The server should be capable of deserializing simple scalar properties + encoded using a map with a definite length.""", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v" + params: { + byteValue: 5, + doubleValue: 1.889, + falseBooleanValue: false, + floatValue: 7.624, + integerValue: 256, + longValue: 9873, + shortValue: 9898, + stringValue: "simple", + trueBooleanValue: true, + blobValue: "foo" + }, + appliesTo: "server" + }, { id: "RpcV2CborClientDoesntSerializeNullStructureValues", documentation: "RpcV2 Cbor should not serialize null structure values", protocol: rpcv2Cbor, method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/SimpleScalarProperties", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", body: "v/8=", bodyMediaType: "application/cbor", headers: { @@ -56,7 +85,7 @@ use smithy.test#httpResponseTests documentation: "RpcV2 Cbor should not deserialize null structure values", protocol: rpcv2Cbor, method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/SimpleScalarProperties", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", body: "v2tzdHJpbmdWYWx1Zfb/", bodyMediaType: "application/cbor", headers: { @@ -120,7 +149,65 @@ use smithy.test#httpResponseTests doubleValue: "-Infinity", floatValue: "-Infinity" } - } + }, + { + id: "RpcV2CborIndefiniteLengthStringsCanBeDeserialized", + protocol: rpcv2Cbor, + documentation: "The server should be capable of deserializing indefinite length text strings.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==" + params: { + stringValue: "An example indefinite string, chunked on comma" + }, + appliesTo: "server" + }, + { + id: "RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized", + protocol: rpcv2Cbor, + documentation: "The server should be capable of deserializing indefinite length byte strings.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==" + params: { + blobValue: "An example indefinite-byte string, chunked on comma" + }, + appliesTo: "server" + }, + { + id: "RpcV2CborSupportsUpcastingData", + protocol: rpcv2Cbor, + documentation: "Supports upcasting from a smaller byte representation of the same date type.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=" + params: { + doubleValue: 1.5, + floatValue: 7.625, + integerValue: 56, + longValue: 256, + shortValue: 10 + }, + appliesTo: "server" + }, ]) @httpResponseTests([ { @@ -132,7 +219,7 @@ use smithy.test#httpResponseTests "Content-Type": "application/cbor" } bodyMediaType: "application/cbor", - body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9f8=", + body: "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//" code: 200, params: { trueBooleanValue: true, @@ -142,9 +229,34 @@ use smithy.test#httpResponseTests floatValue: 7.624, integerValue: 256, shortValue: 9898, - stringValue: "simple" + stringValue: "simple", + blobValue: "foo" } }, + { + id: "RpcV2CborSimpleScalarPropertiesUsingDefiniteLength", + protocol: rpcv2Cbor, + documentation: "Deserializes simple scalar properties encoded using a map with definite length", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + bodyMediaType: "application/cbor", + body: "qXB0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb28=" + code: 200, + params: { + trueBooleanValue: true, + falseBooleanValue: false, + byteValue: 5, + doubleValue: 1.889, + floatValue: 7.624, + integerValue: 256, + shortValue: 9898, + stringValue: "simple", + blobValue: "foo" + }, + appliesTo: "client" + }, { id: "RpcV2CborClientDoesntDeSerializeNullStructureValues", documentation: "RpcV2 Cbor should deserialize null structure values", @@ -286,6 +398,33 @@ apply RecursiveShapes @httpResponseTests([ } } } + }, + { + id: "RpcV2CborRecursiveShapesUsingDefiniteLength", + documentation: "Deserializes recursive structures encoded using a map with definite length", + protocol: rpcv2Cbor, + code: 200, + body: "oWZuZXN0ZWSiY2Zvb2RGb28xZm5lc3RlZKJjYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyomNmb29kRm9vMmZuZXN0ZWShY2JhcmRCYXIy" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + nested: { + foo: "Foo1", + nested: { + bar: "Bar1", + recursiveMember: { + foo: "Foo2", + nested: { + bar: "Bar2" + } + } + } + } + }, + appliesTo: "client" } ]) @@ -308,7 +447,6 @@ structure RecursiveShapesInputOutputNested2 { recursiveMember: RecursiveShapesInputOutputNested1, } - structure SimpleScalarStructure { trueBooleanValue: Boolean, falseBooleanValue: Boolean, @@ -319,4 +457,5 @@ structure SimpleScalarStructure { longValue: Long, shortValue: Short, stringValue: String, -} \ No newline at end of file + blobValue: Blob +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy index 1a03e77919e..f497e405fa5 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy @@ -21,7 +21,7 @@ use smithy.test#httpResponseTests "X-Amz-Target" ] method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + uri: "/service/RpcV2Protocol/operation/NoInputOutput", body: "" }, { @@ -34,7 +34,7 @@ use smithy.test#httpResponseTests "Content-Type": "application/cbor" } method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + uri: "/service/RpcV2Protocol/operation/NoInputOutput", body: "", appliesTo: "server" }, @@ -48,7 +48,7 @@ use smithy.test#httpResponseTests "Content-Type": "application/cbor" } method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + uri: "/service/RpcV2Protocol/operation/NoInputOutput", body: "v/8=", appliesTo: "server" }, @@ -62,7 +62,7 @@ use smithy.test#httpResponseTests "Content-Type": "application/cbor" } method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/NoInputOutput", + uri: "/service/RpcV2Protocol/operation/NoInputOutput", body: "v/8=", appliesTo: "server" } @@ -126,7 +126,8 @@ operation NoInputOutput {} "X-Amz-Target" ] method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/EmptyInputOutput", + uri: "/service/RpcV2Protocol/operation/EmptyInputOutput", + bodyMediaType: "application/cbor", body: "v/8=", }, ]) @@ -163,7 +164,8 @@ operation EmptyInputOutput { "X-Amz-Target" ] method: "POST", - uri: "/service/aws.protocoltests.rpcv2Cbor.RpcV2Protocol/operation/OptionalInputOutput", + uri: "/service/RpcV2Protocol/operation/OptionalInputOutput", + bodyMediaType: "application/cbor", body: "v/8=", }, ]) diff --git a/smithy-aws-protocol-tests/model/rpcV2/errors.smithy b/smithy-aws-protocol-tests/model/rpcV2/errors.smithy index 5010cfa50ef..0fbaf3f6eae 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/errors.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/errors.smithy @@ -43,7 +43,7 @@ apply InvalidGreeting @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4J2F3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0ludmFsaWRHcmVldGluZ2dNZXNzYWdlYkhp/w==", + body: "v2ZfX3R5cGV4K2F3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", bodyMediaType: "application/cbor", }, ]) @@ -75,7 +75,7 @@ apply ComplexError @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4JGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0NvbXBsZXhFcnJvcmZOZXN0ZWS/Y0Zvb2NiYXL/aFRvcExldmVsaVRvcCBsZXZlbP8=", + body: "v2ZfX3R5cGV4KGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", bodyMediaType: "application/cbor" }, { @@ -83,11 +83,10 @@ apply ComplexError @httpResponseTests([ protocol: rpcv2Cbor, code: 400, headers: { - "Content-Type": "application/x-amz-json-1.1" + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4JGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyI0NvbXBsZXhFcnJvcv8=", + body: "v2ZfX3R5cGV4KGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/", bodyMediaType: "application/cbor" }, ]) - - diff --git a/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy b/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy index 8be731e963e..5fc19157a73 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy @@ -19,6 +19,10 @@ apply FractionalSeconds @httpResponseTests([ protocol: rpcv2Cbor, code: 200, body: "v2hkYXRldGltZcH7Qcw32zgPvnf/", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, params: { datetime: 946845296.123 } bodyMediaType: "application/cbor", appliesTo: "client" diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-aws-protocol-tests/model/rpcV2/main.smithy index 1ea3dfa683d..2bf5b073fe2 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/main.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/main.smithy @@ -20,7 +20,8 @@ service RpcV2Protocol { RpcV2CborMaps, RecursiveShapes, GreetingWithErrors, - FractionalSeconds + FractionalSeconds, + OperationWithDefaults ] } @@ -30,4 +31,4 @@ structure EmptyStructure { structure SimpleStructure { value: String, -} \ No newline at end of file +} From 63432da28da2831d1fdfd6dfd93bb47c045ef630 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Wed, 13 Mar 2024 20:31:49 +0000 Subject: [PATCH 12/30] Add default value tests --- .../model/rpcV2/defaults.smithy | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 smithy-aws-protocol-tests/model/rpcV2/defaults.smithy diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy new file mode 100644 index 00000000000..f4868be0867 --- /dev/null +++ b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy @@ -0,0 +1,247 @@ +$version: "2.0" + +namespace aws.protocoltests.rpcv2Cbor + +use smithy.protocols#rpcv2Cbor +use smithy.test#httpRequestTests +use smithy.test#httpResponseTests +use smithy.framework#ValidationException + +apply OperationWithDefaults @httpRequestTests([ + { + id: "RpcV2CborClientPopulatesDefaultValuesInInput" + documentation: "Client populates default values in input." + protocol: rpcv2Cbor + appliesTo: "client" + tags: ["defaults"] + method: "POST" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + bodyMediaType: "application/cbor" + body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" + params: { + defaults: {} + } + } + { + id: "RpcV2CborClientSkipsTopLevelDefaultValuesInInput" + documentation: "Client skips top level default values in input." + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + method: "POST" + bodyMediaType: "application/cbor" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + body: "v/8=" + params: { + } + } + { + id: "RpcV2CborClientUsesExplicitlyProvidedMemberValuesOverDefaults" + documentation: "Client uses explicitly provided member values over defaults" + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + method: "POST" + bodyMediaType: "application/cbor" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXABa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl+0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C/w==" + params: { + defaults: { + defaultString: "bye", + defaultBoolean: true, + defaultList: ["a"], + defaultTimestamp: 1, + defaultBlob: "hi", + defaultByte: 2, + defaultShort: 2, + defaultInteger: 20, + defaultLong: 200, + defaultFloat: 2.0, + defaultDouble: 2.0, + defaultMap: {name: "Jack"}, + defaultEnum: "BAR", + defaultIntEnum: 2 + } + } + } + { + id: "RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody" + documentation: "Server populates default values when missing in request body." + appliesTo: "server" + tags: ["defaults"] + protocol: rpcv2Cbor + method: "POST" + bodyMediaType: "application/cbor" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + body: "v2hkZWZhdWx0c6D/" + params: { + defaults: { + defaultString: "hi" + defaultBoolean: true + defaultList: [] + defaultTimestamp: 0 + defaultBlob: "abc" + defaultByte: 1 + defaultShort: 1 + defaultInteger: 10 + defaultLong: 100 + defaultFloat: 1.0 + defaultDouble: 1.0 + defaultMap: {} + defaultEnum: "FOO" + defaultIntEnum: 1 + }, + topLevelDefault: "hi" + } + } +]) + +apply OperationWithDefaults @httpResponseTests([ + { + id: "RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse" + documentation: "Client populates default values when missing in response." + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + code: 200 + bodyMediaType: "application/cbor" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + body: "v/8=" + params: { + defaultString: "hi" + defaultBoolean: true + defaultList: [] + defaultTimestamp: 0 + defaultBlob: "abc" + defaultByte: 1 + defaultShort: 1 + defaultInteger: 10 + defaultLong: 100 + defaultFloat: 1.0 + defaultDouble: 1.0 + defaultMap: {} + defaultEnum: "FOO" + defaultIntEnum: 1 + } + } + { + id: "RpcV2CborClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse" + documentation: "Client ignores default values if member values are present in the response." + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + code: 200 + bodyMediaType: "application/cbor" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcAJrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL/" + params: { + defaultString: "bye", + defaultBoolean: false, + defaultList: ["a"], + defaultTimestamp: 2, + defaultBlob: "hi", + defaultByte: 2, + defaultShort: 2, + defaultInteger: 20, + defaultLong: 200, + defaultFloat: 2.0, + defaultDouble: 2.0, + defaultMap: {name: "Jack"}, + defaultEnum: "BAR", + defaultIntEnum: 2 + } + } + { + id: "RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams" + documentation: "Server populates default values in response when missing in params." + appliesTo: "server" + tags: ["defaults"] + protocol: rpcv2Cbor + code: 200 + bodyMediaType: "application/cbor" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" + params: {} + } +]) + +operation OperationWithDefaults { + input := { + defaults: Defaults + + topLevelDefault: String = "hi" // Client should ignore default values in input shape + } + + output := with [DefaultsMixin] {} + + errors: [ValidationException] +} + +structure Defaults with [DefaultsMixin] {} + +@mixin +structure DefaultsMixin { + defaultString: String = "hi" + defaultBoolean: Boolean = true + defaultList: TestStringList = [] + defaultTimestamp: Timestamp = 0 + defaultBlob: Blob = "abc" + defaultByte: Byte = 1 + defaultShort: Short = 1 + defaultInteger: Integer = 10 + defaultLong: Long = 100 + defaultFloat: Float = 1.0 + defaultDouble: Double = 1.0 + defaultMap: TestStringMap = {} + defaultEnum: TestEnum = "FOO" + defaultIntEnum: TestIntEnum = 1 +} + +list TestStringList { + member: String +} + +map TestStringMap { + key: String + value: String +} + +enum TestEnum { + FOO + BAR + BAZ +} + +intEnum TestIntEnum { + ONE = 1 + TWO = 2 +} From 2d1c60738d9670b3af7b830fc2132bbb0b57c824 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Thu, 14 Mar 2024 18:05:52 +0000 Subject: [PATCH 13/30] Fix timestamps used in default value tests --- .../model/rpcV2/defaults.smithy | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy index f4868be0867..165d4e2fd3c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy @@ -22,7 +22,8 @@ apply OperationWithDefaults @httpRequestTests([ "Content-Type": "application/cbor" }, bodyMediaType: "application/cbor" - body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3SAcGRlZmF1bHRUaW1lc3RhbXDB%2BwAAAAAAAAAAa2RlZmF1bHRCbG9iY2FiY2tkZWZhdWx0Qnl0ZQFsZGVmYXVsdFNob3J0AW5kZWZhdWx0SW50ZWdlcgprZGVmYXVsdExvbmcYZGxkZWZhdWx0RmxvYXT7P%2FAAAAAAAABtZGVmYXVsdERvdWJsZfs%2F8AAAAAAAAGpkZWZhdWx0TWFwoGtkZWZhdWx0RW51bWNGT09uZGVmYXVsdEludEVudW0B%2Fw%3D%3D + body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3SAcGRlZmF1bHRUaW1lc3RhbXDB+wAAAAAAAAAAa2RlZmF1bHRCbG9iY2FiY2tkZWZhdWx0Qnl0ZQFsZGVmYXVsdFNob3J0AW5kZWZhdWx0SW50ZWdlcgprZGVmYXVsdExvbmcYZGxkZWZhdWx0RmxvYXT7P/AAAAAAAABtZGVmYXVsdERvdWJsZfs/8AAAAAAAAGpkZWZhdWx0TWFwoGtkZWZhdWx0RW51bWNGT09uZGVmYXVsdEludEVudW0B/w==" params: { defaults: {} } @@ -41,6 +42,7 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { } @@ -59,7 +61,8 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXABa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl+0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C/w==" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB%2Bz%2FwAAAAAAAAa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl%2B0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C%2Fw%3D%3D + body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl+0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C/w==" params: { defaults: { defaultString: "bye", @@ -93,6 +96,7 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c6D%2F body: "v2hkZWZhdWx0c6D/" params: { defaults: { @@ -129,6 +133,7 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { defaultString: "hi" @@ -159,7 +164,8 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcAJrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL/" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0%2B0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL%2F + body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL/" params: { defaultString: "bye", defaultBoolean: false, @@ -189,7 +195,8 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs%2F8AAAAAAAAG1kZWZhdWx0RG91Ymxl%2Bz%2FwAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH%2F + body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" params: {} } ]) From 0e0c750f8c3f83a2dab67c1d1589913704bb79ca Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Thu, 14 Mar 2024 18:07:06 +0000 Subject: [PATCH 14/30] Remove debug URLs from the default tests --- smithy-aws-protocol-tests/model/rpcV2/defaults.smithy | 7 ------- 1 file changed, 7 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy index 165d4e2fd3c..c56344f6b35 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy @@ -22,7 +22,6 @@ apply OperationWithDefaults @httpRequestTests([ "Content-Type": "application/cbor" }, bodyMediaType: "application/cbor" - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3SAcGRlZmF1bHRUaW1lc3RhbXDB%2BwAAAAAAAAAAa2RlZmF1bHRCbG9iY2FiY2tkZWZhdWx0Qnl0ZQFsZGVmYXVsdFNob3J0AW5kZWZhdWx0SW50ZWdlcgprZGVmYXVsdExvbmcYZGxkZWZhdWx0RmxvYXT7P%2FAAAAAAAABtZGVmYXVsdERvdWJsZfs%2F8AAAAAAAAGpkZWZhdWx0TWFwoGtkZWZhdWx0RW51bWNGT09uZGVmYXVsdEludEVudW0B%2Fw%3D%3D body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3SAcGRlZmF1bHRUaW1lc3RhbXDB+wAAAAAAAAAAa2RlZmF1bHRCbG9iY2FiY2tkZWZhdWx0Qnl0ZQFsZGVmYXVsdFNob3J0AW5kZWZhdWx0SW50ZWdlcgprZGVmYXVsdExvbmcYZGxkZWZhdWx0RmxvYXT7P/AAAAAAAABtZGVmYXVsdERvdWJsZfs/8AAAAAAAAGpkZWZhdWx0TWFwoGtkZWZhdWx0RW51bWNGT09uZGVmYXVsdEludEVudW0B/w==" params: { defaults: {} @@ -42,7 +41,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { } @@ -61,7 +59,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB%2Bz%2FwAAAAAAAAa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl%2B0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C%2Fw%3D%3D body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl+0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C/w==" params: { defaults: { @@ -96,7 +93,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c6D%2F body: "v2hkZWZhdWx0c6D/" params: { defaults: { @@ -133,7 +129,6 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { defaultString: "hi" @@ -164,7 +159,6 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0%2B0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL%2F body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL/" params: { defaultString: "bye", @@ -195,7 +189,6 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs%2F8AAAAAAAAG1kZWZhdWx0RG91Ymxl%2Bz%2FwAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH%2F body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" params: {} } From 42ebb51dc77dee34221c73cfbf8fabb738db13ce Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 15 Mar 2024 00:33:32 +0000 Subject: [PATCH 15/30] Fix encoded floats to be 4 bytes, and blobs to be Byte strings in default tests --- .../model/rpcV2/defaults.smithy | 143 +++++++++++++++--- 1 file changed, 121 insertions(+), 22 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy index c56344f6b35..751585f01a6 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy @@ -22,7 +22,8 @@ apply OperationWithDefaults @httpRequestTests([ "Content-Type": "application/cbor" }, bodyMediaType: "application/cbor" - body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3SAcGRlZmF1bHRUaW1lc3RhbXDB+wAAAAAAAAAAa2RlZmF1bHRCbG9iY2FiY2tkZWZhdWx0Qnl0ZQFsZGVmYXVsdFNob3J0AW5kZWZhdWx0SW50ZWdlcgprZGVmYXVsdExvbmcYZGxkZWZhdWx0RmxvYXT7P/AAAAAAAABtZGVmYXVsdERvdWJsZfs/8AAAAAAAAGpkZWZhdWx0TWFwoGtkZWZhdWx0RW51bWNGT09uZGVmYXVsdEludEVudW0B/w==" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo%2FgAAAbWRlZmF1bHREb3VibGX7P%2FAAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0%2BgAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8%3D + body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=" params: { defaults: {} } @@ -41,6 +42,7 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { } @@ -59,7 +61,8 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - body: "v2hkZWZhdWx0c65tZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iYmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPtAAAAAAAAAAG1kZWZhdWx0RG91Ymxl+0AAAAAAAAAAamRlZmF1bHRNYXChZG5hbWVkSmFja2tkZWZhdWx0RW51bWNCQVJuZGVmYXVsdEludEVudW0C/w==" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB%2Bz%2FwAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0%2Bj%2BAAABqemVyb0RvdWJsZfs%2F8AAAAAAAAP8%3D + body: "v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0+j+AAABqemVyb0RvdWJsZfs/8AAAAAAAAP8=" params: { defaults: { defaultString: "bye", @@ -75,7 +78,16 @@ apply OperationWithDefaults @httpRequestTests([ defaultDouble: 2.0, defaultMap: {name: "Jack"}, defaultEnum: "BAR", - defaultIntEnum: 2 + defaultIntEnum: 2, + emptyString: "foo", + falseBoolean: true, + emptyBlob: "hi", + zeroByte: 1, + zeroShort: 1, + zeroInteger: 1, + zeroLong: 1, + zeroFloat: 1.0, + zeroDouble: 1.0 } } } @@ -93,25 +105,77 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c6D%2F body: "v2hkZWZhdWx0c6D/" params: { defaults: { - defaultString: "hi" - defaultBoolean: true - defaultList: [] - defaultTimestamp: 0 - defaultBlob: "abc" - defaultByte: 1 - defaultShort: 1 - defaultInteger: 10 - defaultLong: 100 - defaultFloat: 1.0 - defaultDouble: 1.0 - defaultMap: {} - defaultEnum: "FOO" - defaultIntEnum: 1 + defaultString: "hi", + defaultBoolean: true, + defaultList: [], + defaultTimestamp: 0, + defaultBlob: "abc", + defaultByte: 1, + defaultShort: 1, + defaultInteger: 10, + defaultLong: 100, + defaultFloat: 1.0, + defaultDouble: 1.0, + defaultMap: {}, + defaultEnum: "FOO", + defaultIntEnum: 1, + emptyString: "", + falseBoolean: false, + emptyBlob: "", + zeroByte: 0, + zeroShort: 0, + zeroInteger: 0, + zeroLong: 0, + zeroFloat: 0.0, + zeroDouble: 0.0 }, - topLevelDefault: "hi" + topLevelDefault: "hi", + otherTopLevelDefault: 0 + } + } + { + id: "RpcV2CborClientUsesExplicitlyProvidedValuesInTopLevel" + documentation: "Any time a value is provided for a member in the top level of input, it is used, regardless of if its the default." + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + method: "POST" + bodyMediaType: "application/cbor" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA%2Fw%3D%3D + body: "v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA/w==" + params: { + topLevelDefault: "hi", + otherTopLevelDefault: 0 + } + } + { + id: "RpcV2CborClientIgnoresNonTopLevelDefaultsOnMembersWithClientOptional" + documentation: "Typically, non top-level members would have defaults filled in, but if they have the clientOptional trait, the defaults should be ignored." + appliesTo: "client" + tags: ["defaults"] + protocol: rpcv2Cbor + method: "POST" + bodyMediaType: "application/cbor" + uri: "/" + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8%3D + body: "v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8=" + params: { + clientOptionalDefaults: {} } } ]) @@ -145,6 +209,15 @@ apply OperationWithDefaults @httpResponseTests([ defaultMap: {} defaultEnum: "FOO" defaultIntEnum: 1 + emptyString: "" + falseBoolean: false + emptyBlob: "" + zeroByte: 0 + zeroShort: 0 + zeroInteger: 0 + zeroLong: 0 + zeroFloat: 0.0 + zeroDouble: 0.0 } } { @@ -159,7 +232,8 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JiaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+0AAAAAAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQL/" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0%2BkAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl%2Bz%2FwAAAAAAAA%2Fw%3D%3D + body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+kAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl+z/wAAAAAAAA/w==" params: { defaultString: "bye", defaultBoolean: false, @@ -174,7 +248,16 @@ apply OperationWithDefaults @httpResponseTests([ defaultDouble: 2.0, defaultMap: {name: "Jack"}, defaultEnum: "BAR", - defaultIntEnum: 2 + defaultIntEnum: 2, + emptyString: "foo", + falseBoolean: true, + emptyBlob: "hi", + zeroByte: 1, + zeroShort: 1, + zeroInteger: 1, + zeroLong: 1, + zeroFloat: 1.0, + zeroDouble: 1.0 } } { @@ -189,7 +272,8 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JjYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPs/8AAAAAAAAG1kZWZhdWx0RG91Ymxl+z/wAAAAAAAAamRlZmF1bHRNYXCga2RlZmF1bHRFbnVtY0ZPT25kZWZhdWx0SW50RW51bQH/" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo%2FgAAAbWRlZmF1bHREb3VibGX7P%2FAAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0%2BgAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8%3D + body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=" params: {} } ]) @@ -197,8 +281,9 @@ apply OperationWithDefaults @httpResponseTests([ operation OperationWithDefaults { input := { defaults: Defaults - + clientOptionalDefaults: ClientOptionalDefaults topLevelDefault: String = "hi" // Client should ignore default values in input shape + otherTopLevelDefault: Integer = 0 } output := with [DefaultsMixin] {} @@ -208,6 +293,11 @@ operation OperationWithDefaults { structure Defaults with [DefaultsMixin] {} +structure ClientOptionalDefaults { + @clientOptional + member: Integer = 0 +} + @mixin structure DefaultsMixin { defaultString: String = "hi" @@ -224,6 +314,15 @@ structure DefaultsMixin { defaultMap: TestStringMap = {} defaultEnum: TestEnum = "FOO" defaultIntEnum: TestIntEnum = 1 + emptyString: String = "" + falseBoolean: Boolean = false + emptyBlob: Blob = "" + zeroByte: Byte = 0 + zeroShort: Short = 0 + zeroInteger: Integer = 0 + zeroLong: Long = 0 + zeroFloat: Float = 0.0 + zeroDouble: Double = 0.0 } list TestStringList { From e20de2f82e5fccb04644d7c6e5d2bd50aa35898b Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 15 Mar 2024 17:33:23 +0000 Subject: [PATCH 16/30] Use an indefinite length key --- smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index b196557c016..e1825b3c38f 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -38,7 +38,8 @@ use smithy.test#httpResponseTests protocol: rpcv2Cbor, documentation: """ The server should be capable of deserializing simple scalar properties - encoded using a map with a definite length.""", + encoded using a map with a definite length. The server should also be able to parse + a key encoded using an indefinite length string.""", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -47,7 +48,8 @@ use smithy.test#httpResponseTests method: "POST", bodyMediaType: "application/cbor", uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", - body: "qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl%2Bz%2F%2BOVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl%2F%2FRqZmxvYXRWYWx1ZfpA8%2FfPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqmtzdHJpbmdWYWx1ZWZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw%3D%3D + body: "qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA8/fPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqmtzdHJpbmdWYWx1ZWZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==" params: { byteValue: 5, doubleValue: 1.889, From c8ce9a82cfe3c5e21f6d8b4167e33367e52cd144 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 15 Mar 2024 17:51:33 +0000 Subject: [PATCH 17/30] Use multiple keys with indefinite length --- smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index e1825b3c38f..4720a1e86b9 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -48,8 +48,8 @@ use smithy.test#httpResponseTests method: "POST", bodyMediaType: "application/cbor", uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl%2Bz%2F%2BOVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl%2F%2FRqZmxvYXRWYWx1ZfpA8%2FfPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqmtzdHJpbmdWYWx1ZWZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw%3D%3D - body: "qmlieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA8/fPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqmtzdHJpbmdWYWx1ZWZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX%2F%2Bz%2F%2BOVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl%2F%2FRqZmxvYXRWYWx1ZfpA8%2FfPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl%2F2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw%3D%3D + body: "qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA8/fPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==" params: { byteValue: 5, doubleValue: 1.889, From a8c1b6f198b962b33ec060a3f38c15dc8f5b755c Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Thu, 21 Mar 2024 19:37:42 +0000 Subject: [PATCH 18/30] Remove debug comments --- smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy | 1 - smithy-aws-protocol-tests/model/rpcV2/defaults.smithy | 8 -------- 2 files changed, 9 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index 4720a1e86b9..ed1d98354e8 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -48,7 +48,6 @@ use smithy.test#httpResponseTests method: "POST", bodyMediaType: "application/cbor", uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX%2F%2Bz%2F%2BOVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl%2F%2FRqZmxvYXRWYWx1ZfpA8%2FfPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl%2F2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw%3D%3D body: "qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA8/fPbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==" params: { byteValue: 5, diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy index 751585f01a6..df22203db9c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy @@ -22,7 +22,6 @@ apply OperationWithDefaults @httpRequestTests([ "Content-Type": "application/cbor" }, bodyMediaType: "application/cbor" - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo%2FgAAAbWRlZmF1bHREb3VibGX7P%2FAAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0%2BgAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8%3D body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=" params: { defaults: {} @@ -42,7 +41,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v%2F8%3D body: "v/8=" params: { } @@ -61,7 +59,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB%2Bz%2FwAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0%2Bj%2BAAABqemVyb0RvdWJsZfs%2F8AAAAAAAAP8%3D body: "v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0+j+AAABqemVyb0RvdWJsZfs/8AAAAAAAAP8=" params: { defaults: { @@ -105,7 +102,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2hkZWZhdWx0c6D%2F body: "v2hkZWZhdWx0c6D/" params: { defaults: { @@ -151,7 +147,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA%2Fw%3D%3D body: "v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA/w==" params: { topLevelDefault: "hi", @@ -172,7 +167,6 @@ apply OperationWithDefaults @httpRequestTests([ "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8%3D body: "v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8=" params: { clientOptionalDefaults: {} @@ -232,7 +226,6 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0%2BkAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl%2Bz%2FwAAAAAAAA%2Fw%3D%3D body: "v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+kAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl+z/wAAAAAAAA/w==" params: { defaultString: "bye", @@ -272,7 +265,6 @@ apply OperationWithDefaults @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo%2FgAAAbWRlZmF1bHREb3VibGX7P%2FAAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0%2BgAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8%3D body: "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=" params: {} } From 04df5efafc9399d24ca569bfd3a3c9b8f380f824 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 15:13:50 +0000 Subject: [PATCH 19/30] Move sparseList/Map test into a separate operation. Add blobList as a member field. --- .../model/rpcV2/cbor-lists.smithy | 175 ++++++++++++++---- .../model/rpcV2/cbor-structs.smithy | 27 ++- .../model/rpcV2/empty-input-output.smithy | 52 ++++-- .../model/rpcV2/main.smithy | 3 +- 4 files changed, 209 insertions(+), 48 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy index d0df8cf5455..9054301e5e4 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy @@ -5,11 +5,13 @@ $version: "2.0" namespace aws.protocoltests.rpcv2Cbor use aws.protocoltests.shared#BooleanList +use aws.protocoltests.shared#BlobList use aws.protocoltests.shared#FooEnumList use aws.protocoltests.shared#IntegerEnumList use aws.protocoltests.shared#IntegerList use aws.protocoltests.shared#NestedStringList use aws.protocoltests.shared#SparseStringList +use aws.protocoltests.shared#SparseStringMap use aws.protocoltests.shared#StringList use aws.protocoltests.shared#StringSet use aws.protocoltests.shared#TimestampList @@ -39,7 +41,8 @@ apply RpcV2CborLists @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - body: "v2tib29sZWFuTGlzdJ/19P9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9raW50ZWdlckxpc3SfAQL/cG5lc3RlZFN0cmluZ0xpc3Sfn2Nmb29jYmFy/59jYmF6Y3F1eP//anN0cmluZ0xpc3SfY2Zvb2NiYXL/aXN0cmluZ1NldJ9jZm9vY2Jhcv9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP//", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX%2B%2FOAAADB%2B0HU1%2FvzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8%3D + body: "v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -94,12 +97,17 @@ apply RpcV2CborLists @httpRequestTests([ "a": "3", "b": "4" } + ], + "blobList" : [ + "foo", + "bar" ] } }, { id: "RpcV2CborListsEmpty", documentation: "Serializes empty JSON lists", + tags: ["client-indefinite"] protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", @@ -117,6 +125,7 @@ apply RpcV2CborLists @httpRequestTests([ { id: "RpcV2CborListsEmptyUsingDefiniteLength", documentation: "Serializes empty JSON definite length lists", + tags: ["client-definite"] protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", @@ -132,12 +141,13 @@ apply RpcV2CborLists @httpRequestTests([ } }, { - id: "RpcV2CborListsSerializeNull", - documentation: "Serializes null values in lists", + id: "RpcV2CborIndefiniteStringInsideIndefiniteList", + documentation: "Can deserialize indefinite length text strings inside an indefinite length list", protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - body: "v3BzcGFyc2VTdHJpbmdMaXN0n/ZiaGn//w==", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n%2F%2F8%3D + body: "v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -145,32 +155,17 @@ apply RpcV2CborLists @httpRequestTests([ "Content-Type": "application/cbor" }, params: { - sparseStringList: [null, "hi"] - } - }, - { - id: "RpcV2CborSparseListWithIndefiniteString", - documentation: "Serializes indefinite length text strings inside an indefinite length list", - protocol: rpcv2Cbor, - method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - body: "v3BzcGFyc2VTdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" - bodyMediaType: "application/cbor", - headers: { - "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", - "Content-Type": "application/cbor" - }, - params: { - sparseStringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] + stringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] } + appliesTo: "server" }, { - id: "RpcV2CborListWithIndefiniteString", - documentation: "Serializes indefinite length text strings inside a definite length list", + id: "RpcV2CborIndefiniteStringInsideDefiniteList", + documentation: "Can deserialize indefinite length text strings inside a definite length list", protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n body: "oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n" bodyMediaType: "application/cbor", headers: { @@ -180,7 +175,8 @@ apply RpcV2CborLists @httpRequestTests([ }, params: { stringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] - } + }, + appliesTo: "server" } ]) @@ -190,7 +186,8 @@ apply RpcV2CborLists @httpResponseTests([ documentation: "Serializes RpcV2 Cbor lists", protocol: rpcv2Cbor, code: 200, - body: "v2tib29sZWFuTGlzdJ/19P9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9raW50ZWdlckxpc3SfAQL/cG5lc3RlZFN0cmluZ0xpc3Sfn2Nmb29jYmFy/59jYmF6Y3F1eP//anN0cmluZ0xpc3SfY2Zvb2NiYXL/aXN0cmluZ1NldJ9jZm9vY2Jhcv9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP//", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n2Nmb29jYmFy%2F2lzdHJpbmdTZXSfY2Zvb2NiYXL%2Fa2ludGVnZXJMaXN0nwEC%2F2tib29sZWFuTGlzdJ%2F19P9tdGltZXN0YW1wTGlzdJ%2FB%2B0HU1%2FvzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew%2F2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ%2BfY2Zvb2NiYXL%2Fn2NiYXpjcXV4%2F%2F9tc3RydWN0dXJlTGlzdJ%2B%2FYWFhMWFiYTL%2Fv2FhYTNhYmE0%2F%2F9oYmxvYkxpc3SfQ2Zvb0NiYXL%2F%2Fw%3D%3D + body: "v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -244,6 +241,10 @@ apply RpcV2CborLists @httpResponseTests([ "a": "3", "b": "4" } + ], + "blobList": [ + "foo", + "bar" ] } }, @@ -263,27 +264,44 @@ apply RpcV2CborLists @httpResponseTests([ } }, { - id: "RpcV2CborListsSerializeNull", - documentation: "Serializes null values in sparse lists", + id: "RpcV2CborIndefiniteStringInsideIndefiniteListCanDeserialize", + documentation: "Can deserialize indefinite length text strings inside an indefinite length list", protocol: rpcv2Cbor, code: 200, - body: "v3BzcGFyc2VTdHJpbmdMaXN0n/ZiaGn//w==", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n%2F%2F8%3D + body: "v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, params: { - sparseStringList: [null, "hi"] + stringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] } + appliesTo: "client" + }, + { + id: "RpcV2CborIndefiniteStringInsideDefiniteListCanDeserialize", + documentation: "Can deserialize indefinite length text strings inside a definite length list", + protocol: rpcv2Cbor, + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n + body: "oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + stringList: ["An example indefinite string, which will be chunked, on each comma", "Another example indefinite string with only one chunk", "This is a plain string"] + }, + appliesTo: "client" } ]) structure RpcV2CborListInputOutput { stringList: StringList, - sparseStringList: SparseStringList, - stringSet: StringSet, integerList: IntegerList, @@ -299,6 +317,8 @@ structure RpcV2CborListInputOutput { nestedStringList: NestedStringList, structureList: StructureList + + blobList: BlobList } list StructureList { @@ -309,3 +329,94 @@ structure StructureListMember { a: String, b: String, } + + +@httpRequestTests([ + { + id: "RpcV2CborSparseMapsSerializeNullValues" + documentation: "Serializes null values in maps" + protocol: rpcv2Cbor + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJpbmdNYXC%2FY2Zvb%2Fb%2F%2Fw%3D%3D + body: "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==" + params: { + "sparseStringMap": { + "foo": null + } + } + method: "POST" + uri: "/" + }, + { + id: "RpcV2CborSparseListsSerializeNull" + documentation: "Serializes null values in lists" + protocol: rpcv2Cbor + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VTdHJpbmdMaXN0n%2Fb%2F%2Fw%3D%3D + body: "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==" + params: { + "sparseStringList": [ + null + ] + } + method: "POST" + uri: "/" + } +]) +@httpResponseTests([ + { + id: "RpcV2CborSparseMapsDeserializeNullValues" + documentation: "Deserializes null values in maps" + protocol: rpcv2Cbor, + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJpbmdNYXC%2FY2Zvb%2Fb%2F%2Fw%3D%3D + body: "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseStringMap": { + "foo": null + } + } + } + { + id: "RpcV2CborSparseListsDeserializeNull" + documentation: "Deserializes null values in lists" + protocol: rpcv2Cbor, + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VTdHJpbmdMaXN0n%2Fb%2F%2Fw%3D%3D + body: "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseStringList": [ + null + ] + } + } +]) +operation SparseNullsOperation { + input: SparseNullsOperationInputOutput + output: SparseNullsOperationInputOutput +} + +structure SparseNullsOperationInputOutput { + sparseStringList: SparseStringList + sparseStringMap: SparseStringMap +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index ed1d98354e8..73b47f80301 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -259,8 +259,8 @@ use smithy.test#httpResponseTests appliesTo: "client" }, { - id: "RpcV2CborClientDoesntDeSerializeNullStructureValues", - documentation: "RpcV2 Cbor should deserialize null structure values", + id: "RpcV2CborClientDoesntDeserializeNullStructureValues", + documentation: "RpcV2 Cbor should not deserialize null structure values", protocol: rpcv2Cbor, body: "v2tzdHJpbmdWYWx1Zfb/", code: 200, @@ -335,7 +335,28 @@ use smithy.test#httpResponseTests doubleValue: "-Infinity", floatValue: "-Infinity" } - } + }, + { + id: "RpcV2CborSupportsUpcastingDataOnDeserialize", + protocol: rpcv2Cbor, + documentation: "Supports upcasting from a smaller byte representation of the same date type.", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + code: 200, + bodyMediaType: "application/cbor", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2tkb3VibGVWYWx1Zfk%2BAGpmbG9hdFZhbHVl%2BUegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8%3D + body: "v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=" + params: { + doubleValue: 1.5, + floatValue: 7.625, + integerValue: 56, + longValue: 256, + shortValue: 10 + }, + appliesTo: "client" + }, ]) operation SimpleScalarProperties { input: SimpleScalarStructure, diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy index f497e405fa5..4234038e203 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy @@ -39,7 +39,7 @@ use smithy.test#httpResponseTests appliesTo: "server" }, { - id: "no_input_server_allows_empty_cbor", + id: "NoInputServerAllowsEmptyCbor", protocol: rpcv2Cbor, documentation: "Servers should accept CBOR empty struct if no input.", headers: { @@ -53,9 +53,9 @@ use smithy.test#httpResponseTests appliesTo: "server" }, { - id: "NoInputServerIngoresUnexpectedFields", + id: "NoInputServerAllowsEmptyBody", protocol: rpcv2Cbor, - documentation: "Servers should accept CBOR empty struct if no input.", + documentation: "Servers should accept empty body if no input.", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -63,7 +63,7 @@ use smithy.test#httpResponseTests } method: "POST", uri: "/service/RpcV2Protocol/operation/NoInputOutput", - body: "v/8=", + body: "", appliesTo: "server" } ]) @@ -83,29 +83,29 @@ use smithy.test#httpResponseTests code: 200, }, { - id: "no_output_client_allows_accept", + id: "NoOutputClientAllowsEmptyCbor", protocol: rpcv2Cbor, - documentation: "Servers should allow the accept header to be set to the default content-type.", + documentation: "Client should accept CBOR empty struct if no output", headers: { "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", "Content-Type": "application/cbor" } - body: "", code: 200, + bodyMediaType: "application/cbor", + body: "v/8=", appliesTo: "client", }, { - id: "no_input_client_allows_empty_cbor", + id: "NoOutputClientAllowsEmptyBody", protocol: rpcv2Cbor, - documentation: "Client should accept CBOR empty struct if no output", + documentation: "Client should accept empty body if no output", headers: { "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", "Content-Type": "application/cbor" } - body: "v/8=", code: 200, + bodyMediaType: "application/cbor", + body: "", appliesTo: "client", } ]) @@ -130,6 +130,21 @@ operation NoInputOutput {} bodyMediaType: "application/cbor", body: "v/8=", }, + { + id: "empty_input_no_body", + protocol: rpcv2Cbor, + documentation: "When Input structure is empty the server should accept an empty body", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + method: "POST", + uri: "/service/RpcV2Protocol/operation/EmptyInputOutput", + bodyMediaType: "application/cbor", + body: "", + appliesTo: "server" + }, ]) @httpResponseTests([ { @@ -144,6 +159,19 @@ operation NoInputOutput {} } code: 200, }, + { + id: "empty_output_no_body", + protocol: rpcv2Cbor, + documentation: "When output structure is empty the client should accept an empty body", + body: "", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + code: 200, + appliesTo: "client" + }, ]) operation EmptyInputOutput { input: EmptyStructure, diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-aws-protocol-tests/model/rpcV2/main.smithy index 2bf5b073fe2..e925c186f3d 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/main.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/main.smithy @@ -21,7 +21,8 @@ service RpcV2Protocol { RecursiveShapes, GreetingWithErrors, FractionalSeconds, - OperationWithDefaults + OperationWithDefaults, + SparseNullsOperation ] } From 1592b214de42005d5feca74547e075ddfb2455af Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 15:38:31 +0000 Subject: [PATCH 20/30] Fix URI for SparseNullsOperation request tests --- smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy index 9054301e5e4..a496fe8cb1c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy @@ -350,7 +350,7 @@ structure StructureListMember { } } method: "POST" - uri: "/" + uri: "/service/RpcV2Protocol/operation/SparseNullsOperation", }, { id: "RpcV2CborSparseListsSerializeNull" @@ -370,7 +370,7 @@ structure StructureListMember { ] } method: "POST" - uri: "/" + uri: "/service/RpcV2Protocol/operation/SparseNullsOperation", } ]) @httpResponseTests([ From 04eeb9d258b10a65e0f667e3f3616df1d8fb6b97 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 16:56:49 +0000 Subject: [PATCH 21/30] Factor out sparseSetMap into separate operation --- .../model/rpcV2/cbor-maps.smithy | 369 +++++++++++------- .../model/rpcV2/cbor-structs.smithy | 4 +- .../model/rpcV2/main.smithy | 3 +- 3 files changed, 230 insertions(+), 146 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy index baf53dc7be1..5710a9dc501 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -12,20 +12,21 @@ use smithy.protocols#rpcv2Cbor use smithy.framework#ValidationException /// The example tests basic map serialization. -operation RpcV2CborMaps { - input: RpcV2CborMapsInputOutput, - output: RpcV2CborMapsInputOutput, +operation RpcV2CborDenseMaps { + input: RpcV2CborDenseMapsInputOutput, + output: RpcV2CborDenseMapsInputOutput, errors: [ValidationException] } -apply RpcV2CborMaps @httpRequestTests([ +apply RpcV2CborDenseMaps @httpRequestTests([ { id: "RpcV2CborMaps", documentation: "Serializes maps", protocol: rpcv2Cbor, method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v25kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZW9zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb6FiaGlldGhlcmVjYmF6oWJoaWNieWX//w==" + uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ%3D%3D + body: "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -40,24 +41,17 @@ apply RpcV2CborMaps @httpRequestTests([ "baz": { "hi": "bye" } - }, - "sparseStructMap": { - "foo": { - "hi": "there" - }, - "baz": { - "hi": "bye" - } } } }, { - id: "RpcV2CborSerializesNullMapValues", - documentation: "Serializes map values in sparse maps", + id: "RpcV2CborSerializesZeroValuesInMaps", + documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" + uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A%3D%3D + body: "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -65,27 +59,21 @@ apply RpcV2CborMaps @httpRequestTests([ "Content-Type": "application/cbor" }, params: { - "sparseBooleanMap": { - "x": null - }, - "sparseNumberMap": { - "x": null - }, - "sparseStringMap": { - "x": null + "denseNumberMap": { + "x": 0 }, - "sparseStructMap": { - "x": null + "denseBooleanMap": { + "x": false } } }, { - id: "RpcV2CborSerializesZeroValuesInMaps", - documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", + id: "RpcV2CborSerializesDenseSetMap", + documentation: "A request that contains a dense map of sets.", protocol: rpcv2Cbor, method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v25kZW5zZU51bWJlck1hcKFheABvc3BhcnNlTnVtYmVyTWFwv2F4AP9vZGVuc2VCb29sZWFuTWFwoWF49HBzcGFyc2VCb29sZWFuTWFwv2F49P//" + uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", + body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", @@ -93,51 +81,68 @@ apply RpcV2CborMaps @httpRequestTests([ "Content-Type": "application/cbor" }, params: { - "denseNumberMap": { - "x": 0 - }, - "sparseNumberMap": { - "x": 0 - }, - "denseBooleanMap": { - "x": false - }, - "sparseBooleanMap": { - "x": false + "denseSetMap": { + "x": [], + "y": ["a", "b"] } } }, +]) + +apply RpcV2CborDenseMaps @httpResponseTests([ { - id: "RpcV2CborSerializesSparseSetMap", - documentation: "A request that contains a sparse map of sets", + id: "RpcV2CborMaps", + documentation: "Deserializes maps", protocol: rpcv2Cbor, - method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v2xzcGFyc2VTZXRNYXC/YXiAYXmCYWFhYv//" + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ%3D%3D + body: "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { - "sparseSetMap": { - "x": [], - "y": ["a", "b"] + "denseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } } } }, { - id: "RpcV2CborSerializesDenseSetMap", - documentation: "A request that contains a dense map of sets.", + id: "RpcV2CborDeserializesZeroValuesInMaps", + documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, - method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi" + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A%3D%3D + body: "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "denseNumberMap": { + "x": 0 + }, + "denseBooleanMap": { + "x": false + } + } + }, + { + id: "RpcV2CborDeserializesDenseSetMap", + documentation: "A response that contains a dense map of sets", + protocol: rpcv2Cbor, + code: 200, + body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { @@ -148,20 +153,21 @@ apply RpcV2CborMaps @httpRequestTests([ } }, { - id: "RpcV2CborSerializesSparseSetMapAndRetainsNull", - documentation: "A request that contains a sparse map of sets.", + id: "RpcV2CborDeserializesDenseSetMapAndSkipsNull", + documentation: """ + Clients SHOULD tolerate seeing a null value in a dense map, and they SHOULD + drop the null key-value pair.""", protocol: rpcv2Cbor, - method: "POST", - uri: "/service/RpcV2Protocol/operation/RpcV2CborMaps", - body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + appliesTo: "client", + code: 200, + body: "oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", - "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { - "sparseSetMap": { + "denseSetMap": { "x": [], "y": ["a", "b"], "z": null @@ -170,27 +176,56 @@ apply RpcV2CborMaps @httpRequestTests([ } ]) -apply RpcV2CborMaps @httpResponseTests([ +structure RpcV2CborDenseMapsInputOutput { + denseStructMap: DenseStructMap, + denseNumberMap: DenseNumberMap, + denseBooleanMap: DenseBooleanMap, + denseStringMap: DenseStringMap, + denseSetMap: DenseSetMap, +} + +map DenseStructMap { + key: String, + value: GreetingStruct +} + +map DenseBooleanMap { + key: String, + value: Boolean +} + +map DenseNumberMap { + key: String, + value: Integer +} + +map DenseStringMap { + key: String, + value: String +} + +map DenseSetMap { + key: String, + value: StringSet +} + + +apply RpcV2CborSparseMaps @httpRequestTests([ { - id: "RpcV2CborMaps", - documentation: "Deserializes maps", + id: "RpcV2CborSparseMaps", + documentation: "Serializes sparse maps", protocol: rpcv2Cbor, - code: 200, - body: "v25kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZW9zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb6FiaGlldGhlcmVjYmF6oWJoaWNieWX//w==" + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJ1Y3RNYXC%2FY2Zvb79iaGlldGhlcmX%2FY2Jher9iaGljYnll%2F%2F%2F%2F + body: "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { - "denseStructMap": { - "foo": { - "hi": "there" - }, - "baz": { - "hi": "bye" - } - }, "sparseStructMap": { "foo": { "hi": "there" @@ -202,14 +237,16 @@ apply RpcV2CborMaps @httpResponseTests([ } }, { - id: "RpcV2CborDeserializesNullMapValues", - documentation: "Deserializes null map values", + id: "RpcV2CborSerializesNullMapValues", + documentation: "Serializes null map values in sparse maps", protocol: rpcv2Cbor, - code: 200, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { @@ -228,62 +265,135 @@ apply RpcV2CborMaps @httpResponseTests([ } }, { - id: "RpcV2CborDeserializesZeroValuesInMaps", + id: "RpcV2CborSerializesSparseSetMap", + documentation: "A request that contains a sparse map of sets", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2F%2F%2F8%3D + body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=" + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"] + } + } + }, + { + id: "RpcV2CborSerializesSparseSetMapAndRetainsNull", + documentation: "A request that contains a sparse map of sets.", + protocol: rpcv2Cbor, + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseSetMap": { + "x": [], + "y": ["a", "b"], + "z": null + } + } + }, + { + id: "RpcV2CborSerializesZeroValuesInSparseMaps", documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, - code: 200, - body: "v25kZW5zZU51bWJlck1hcKFheABvc3BhcnNlTnVtYmVyTWFwv2F4AP9vZGVuc2VCb29sZWFuTWFwoWF49HBzcGFyc2VCb29sZWFuTWFwv2F49P//" + method: "POST", + uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VOdW1iZXJNYXC%2FYXgA%2F3BzcGFyc2VCb29sZWFuTWFwv2F49P%2F%2F + body: "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", "Content-Type": "application/cbor" }, params: { - "denseNumberMap": { - "x": 0 - }, "sparseNumberMap": { "x": 0 }, - "denseBooleanMap": { - "x": false - }, "sparseBooleanMap": { "x": false } } + } +]) + +apply RpcV2CborSparseMaps @httpResponseTests([ + { + id: "RpcV2CborSparseJsonMaps", + documentation: "Deserializes sparse maps", + protocol: rpcv2Cbor, + code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJ1Y3RNYXC%2FY2Zvb79iaGlldGhlcmX%2FY2Jher9iaGljYnll%2F%2F%2F%2F + body: "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", + bodyMediaType: "application/cbor", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + }, + params: { + "sparseStructMap": { + "foo": { + "hi": "there" + }, + "baz": { + "hi": "bye" + } + } + } }, { - id: "RpcV2CborDeserializesSparseSetMap", - documentation: "A response that contains a sparse map of sets", + id: "RpcV2CborDeserializesNullMapValues", + documentation: "Deserializes null map values", protocol: rpcv2Cbor, code: 200, - body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", + body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, params: { - "sparseSetMap": { - "x": [], - "y": ["a", "b"] + "sparseBooleanMap": { + "x": null + }, + "sparseNumberMap": { + "x": null + }, + "sparseStringMap": { + "x": null + }, + "sparseStructMap": { + "x": null } } }, { - id: "RpcV2CborDeserializesDenseSetMap", - documentation: "A response that contains a dense map of sets.", + id: "RpcV2CborDeserializesSparseSetMap", + documentation: "A response that contains a sparse map of sets", protocol: rpcv2Cbor, code: 200, - body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi" + body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, params: { - "denseSetMap": { + "sparseSetMap": { "x": [], "y": ["a", "b"] } @@ -291,7 +401,7 @@ apply RpcV2CborMaps @httpResponseTests([ }, { id: "RpcV2CborDeserializesSparseSetMapAndRetainsNull", - documentation: "A response that contains a sparse map of sets.", + documentation: "A response that contains a sparse map of sets with a null", protocol: rpcv2Cbor, code: 200, body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", @@ -309,68 +419,47 @@ apply RpcV2CborMaps @httpResponseTests([ } }, { - id: "RpcV2CborDeserializesDenseSetMapAndSkipsNull", - documentation: """ - Clients SHOULD tolerate seeing a null value in a dense map, and they SHOULD - drop the null key-value pair.""", + id: "RpcV2CborDeserializesZeroValuesInSparseMaps", + documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, - appliesTo: "client", code: 200, - body: "oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2" + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VOdW1iZXJNYXC%2FYXgA%2F3BzcGFyc2VCb29sZWFuTWFwv2F49P%2F%2F + body: "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, params: { - "denseSetMap": { - "x": [], - "y": ["a", "b"], - "z": null + "sparseNumberMap": { + "x": 0 + }, + "sparseBooleanMap": { + "x": false } } } ]) -structure RpcV2CborMapsInputOutput { - denseStructMap: DenseStructMap, +operation RpcV2CborSparseMaps { + input: RpcV2CborSparseMapsInputOutput + output: RpcV2CborSparseMapsInputOutput +} + +structure RpcV2CborSparseMapsInputOutput { sparseStructMap: SparseStructMap, - denseNumberMap: DenseNumberMap, - denseBooleanMap: DenseBooleanMap, - denseStringMap: DenseStringMap, sparseNumberMap: SparseNumberMap, sparseBooleanMap: SparseBooleanMap, sparseStringMap: SparseStringMap, - denseSetMap: DenseSetMap, sparseSetMap: SparseSetMap, } -map DenseStructMap { - key: String, - value: GreetingStruct -} - @sparse map SparseStructMap { key: String, value: GreetingStruct } -map DenseBooleanMap { - key: String, - value: Boolean -} - -map DenseNumberMap { - key: String, - value: Integer -} - -map DenseStringMap { - key: String, - value: String -} - @sparse map SparseBooleanMap { key: String, @@ -383,14 +472,8 @@ map SparseNumberMap { value: Integer } -map DenseSetMap { - key: String, - value: StringSet -} - @sparse map SparseSetMap { key: String, value: StringSet } - diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index 73b47f80301..41cc631ef49 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -190,7 +190,7 @@ use smithy.test#httpResponseTests { id: "RpcV2CborSupportsUpcastingData", protocol: rpcv2Cbor, - documentation: "Supports upcasting from a smaller byte representation of the same date type.", + documentation: "Supports upcasting from a smaller byte representation of the same data type.", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -339,7 +339,7 @@ use smithy.test#httpResponseTests { id: "RpcV2CborSupportsUpcastingDataOnDeserialize", protocol: rpcv2Cbor, - documentation: "Supports upcasting from a smaller byte representation of the same date type.", + documentation: "Supports upcasting from a smaller byte representation of the same data type.", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-aws-protocol-tests/model/rpcV2/main.smithy index e925c186f3d..afe2794f79c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/main.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/main.smithy @@ -17,7 +17,8 @@ service RpcV2Protocol { OptionalInputOutput, SimpleScalarProperties, RpcV2CborLists, - RpcV2CborMaps, + RpcV2CborDenseMaps, + RpcV2CborSparseMaps, RecursiveShapes, GreetingWithErrors, FractionalSeconds, From f7610e0317e43f3deb6ea14d2d24d335c1928475 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 17:01:51 +0000 Subject: [PATCH 22/30] Add debug comment URL --- smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy index 5710a9dc501..a7a62ef3017 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -73,6 +73,7 @@ apply RpcV2CborDenseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKJheIBheYJhYWFi body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { @@ -139,6 +140,7 @@ apply RpcV2CborDenseMaps @httpResponseTests([ documentation: "A response that contains a dense map of sets", protocol: rpcv2Cbor, code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKJheIBheYJhYWFi body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { @@ -160,6 +162,7 @@ apply RpcV2CborDenseMaps @httpResponseTests([ protocol: rpcv2Cbor, appliesTo: "client", code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2 body: "oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2", bodyMediaType: "application/cbor", headers: { @@ -242,6 +245,7 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v%2F%2F body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { @@ -291,6 +295,7 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2FYXr2%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", bodyMediaType: "application/cbor", headers: { @@ -360,6 +365,7 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "Deserializes null map values", protocol: rpcv2Cbor, code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v%2F%2F body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { @@ -386,6 +392,7 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "A response that contains a sparse map of sets", protocol: rpcv2Cbor, code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXmfYWFhYv9heJ%2F%2F%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", bodyMediaType: "application/cbor", headers: { @@ -404,6 +411,7 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "A response that contains a sparse map of sets with a null", protocol: rpcv2Cbor, code: 200, + // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2FYXr2%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", bodyMediaType: "application/cbor", headers: { From 4be707a8f1460d0f8b0d90a0d8e634ddaf8d2d12 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 20:33:14 +0000 Subject: [PATCH 23/30] Remove redundant test `no_input_server_allows_accept`. Change documentation to clarify test. --- .../model/rpcV2/empty-input-output.smithy | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy index 4234038e203..6635fe7237c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy @@ -24,20 +24,6 @@ use smithy.test#httpResponseTests uri: "/service/RpcV2Protocol/operation/NoInputOutput", body: "" }, - { - id: "no_input_server_allows_accept", - protocol: rpcv2Cbor, - 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/RpcV2Protocol/operation/NoInputOutput", - body: "", - appliesTo: "server" - }, { id: "NoInputServerAllowsEmptyCbor", protocol: rpcv2Cbor, @@ -55,7 +41,9 @@ use smithy.test#httpResponseTests { id: "NoInputServerAllowsEmptyBody", protocol: rpcv2Cbor, - documentation: "Servers should accept empty body if no input.", + documentation: """ + Servers should accept an empty body if there is no input. Additionally, + they should not raise an error if the `Accept` header is set.""" headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -71,7 +59,7 @@ use smithy.test#httpResponseTests { id: "no_output", protocol: rpcv2Cbor, - documentation: "Body is empty and no Content-Type header if no response", + documentation: "A `Content-Type` header should not be set if the response body is empty.", body: "", bodyMediaType: "application/cbor", headers: { @@ -85,7 +73,7 @@ use smithy.test#httpResponseTests { id: "NoOutputClientAllowsEmptyCbor", protocol: rpcv2Cbor, - documentation: "Client should accept CBOR empty struct if no output", + documentation: "Clients should accept a CBOR empty struct if there is no output.", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" @@ -98,7 +86,9 @@ use smithy.test#httpResponseTests { id: "NoOutputClientAllowsEmptyBody", protocol: rpcv2Cbor, - documentation: "Client should accept empty body if no output", + documentation: """ + Clients should accept an empty body if there is no output and + should not raise an error if the `Content-Type` header is set.""", headers: { "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" From 4f0af19199222261086eee5c67eae562c28dfd41 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 20:33:28 +0000 Subject: [PATCH 24/30] Remove debug URLs --- .../model/rpcV2/cbor-lists.smithy | 10 ---------- .../model/rpcV2/cbor-maps.smithy | 17 ----------------- .../model/rpcV2/cbor-structs.smithy | 1 - 3 files changed, 28 deletions(-) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy index a496fe8cb1c..17b85016f46 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy @@ -41,7 +41,6 @@ apply RpcV2CborLists @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX%2B%2FOAAADB%2B0HU1%2FvzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8%3D body: "v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=" bodyMediaType: "application/cbor", headers: { @@ -146,7 +145,6 @@ apply RpcV2CborLists @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n%2F%2F8%3D body: "v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" bodyMediaType: "application/cbor", headers: { @@ -165,7 +163,6 @@ apply RpcV2CborLists @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborLists", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n body: "oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n" bodyMediaType: "application/cbor", headers: { @@ -186,7 +183,6 @@ apply RpcV2CborLists @httpResponseTests([ documentation: "Serializes RpcV2 Cbor lists", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n2Nmb29jYmFy%2F2lzdHJpbmdTZXSfY2Zvb2NiYXL%2Fa2ludGVnZXJMaXN0nwEC%2F2tib29sZWFuTGlzdJ%2F19P9tdGltZXN0YW1wTGlzdJ%2FB%2B0HU1%2FvzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew%2F2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ%2BfY2Zvb2NiYXL%2Fn2NiYXpjcXV4%2F%2F9tc3RydWN0dXJlTGlzdJ%2B%2FYWFhMWFiYTL%2Fv2FhYTNhYmE0%2F%2F9oYmxvYkxpc3SfQ2Zvb0NiYXL%2F%2Fw%3D%3D body: "v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==" bodyMediaType: "application/cbor", headers: { @@ -268,7 +264,6 @@ apply RpcV2CborLists @httpResponseTests([ documentation: "Can deserialize indefinite length text strings inside an indefinite length list", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n%2F%2F8%3D body: "v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=" bodyMediaType: "application/cbor", headers: { @@ -285,7 +280,6 @@ apply RpcV2CborLists @httpResponseTests([ documentation: "Can deserialize indefinite length text strings inside a definite length list", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h%2F394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r%2F3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n body: "oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n" bodyMediaType: "application/cbor", headers: { @@ -342,7 +336,6 @@ structure StructureListMember { "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJpbmdNYXC%2FY2Zvb%2Fb%2F%2Fw%3D%3D body: "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==" params: { "sparseStringMap": { @@ -362,7 +355,6 @@ structure StructureListMember { "Accept": "application/cbor", "Content-Type": "application/cbor" }, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VTdHJpbmdMaXN0n%2Fb%2F%2Fw%3D%3D body: "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==" params: { "sparseStringList": [ @@ -379,7 +371,6 @@ structure StructureListMember { documentation: "Deserializes null values in maps" protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJpbmdNYXC%2FY2Zvb%2Fb%2F%2Fw%3D%3D body: "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==" bodyMediaType: "application/cbor", headers: { @@ -397,7 +388,6 @@ structure StructureListMember { documentation: "Deserializes null values in lists" protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VTdHJpbmdMaXN0n%2Fb%2F%2Fw%3D%3D body: "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==" bodyMediaType: "application/cbor", headers: { diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy index a7a62ef3017..d0b502b36c8 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -25,7 +25,6 @@ apply RpcV2CborDenseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ%3D%3D body: "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==" bodyMediaType: "application/cbor", headers: { @@ -50,7 +49,6 @@ apply RpcV2CborDenseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A%3D%3D body: "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", bodyMediaType: "application/cbor", headers: { @@ -73,7 +71,6 @@ apply RpcV2CborDenseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKJheIBheYJhYWFi body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { @@ -96,7 +93,6 @@ apply RpcV2CborDenseMaps @httpResponseTests([ documentation: "Deserializes maps", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ%3D%3D body: "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", bodyMediaType: "application/cbor", headers: { @@ -119,7 +115,6 @@ apply RpcV2CborDenseMaps @httpResponseTests([ documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A%3D%3D body: "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", bodyMediaType: "application/cbor", headers: { @@ -140,7 +135,6 @@ apply RpcV2CborDenseMaps @httpResponseTests([ documentation: "A response that contains a dense map of sets", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKJheIBheYJhYWFi body: "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", bodyMediaType: "application/cbor", headers: { @@ -162,7 +156,6 @@ apply RpcV2CborDenseMaps @httpResponseTests([ protocol: rpcv2Cbor, appliesTo: "client", code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2 body: "oWtkZW5zZVNldE1hcKNheIBheYJhYWFiYXr2", bodyMediaType: "application/cbor", headers: { @@ -220,7 +213,6 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJ1Y3RNYXC%2FY2Zvb79iaGlldGhlcmX%2FY2Jher9iaGljYnll%2F%2F%2F%2F body: "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", bodyMediaType: "application/cbor", headers: { @@ -245,7 +237,6 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v%2F%2F body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { @@ -274,7 +265,6 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2F%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=" bodyMediaType: "application/cbor", headers: { @@ -295,7 +285,6 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2FYXr2%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", bodyMediaType: "application/cbor", headers: { @@ -317,7 +306,6 @@ apply RpcV2CborSparseMaps @httpRequestTests([ protocol: rpcv2Cbor, method: "POST", uri: "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VOdW1iZXJNYXC%2FYXgA%2F3BzcGFyc2VCb29sZWFuTWFwv2F49P%2F%2F body: "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { @@ -342,7 +330,6 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "Deserializes sparse maps", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VTdHJ1Y3RNYXC%2FY2Zvb79iaGlldGhlcmX%2FY2Jher9iaGljYnll%2F%2F%2F%2F body: "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", bodyMediaType: "application/cbor", headers: { @@ -365,7 +352,6 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "Deserializes null map values", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v%2F%2F body: "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//" bodyMediaType: "application/cbor", headers: { @@ -392,7 +378,6 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "A response that contains a sparse map of sets", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXmfYWFhYv9heJ%2F%2F%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", bodyMediaType: "application/cbor", headers: { @@ -411,7 +396,6 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "A response that contains a sparse map of sets with a null", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2xzcGFyc2VTZXRNYXC%2FYXif%2F2F5n2FhYWL%2FYXr2%2F%2F8%3D body: "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", bodyMediaType: "application/cbor", headers: { @@ -431,7 +415,6 @@ apply RpcV2CborSparseMaps @httpResponseTests([ documentation: "Ensure that 0 and false are sent over the wire in all maps and lists", protocol: rpcv2Cbor, code: 200, - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v29zcGFyc2VOdW1iZXJNYXC%2FYXgA%2F3BzcGFyc2VCb29sZWFuTWFwv2F49P%2F%2F body: "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//" bodyMediaType: "application/cbor", headers: { diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy index 41cc631ef49..3e88a0564d3 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy @@ -346,7 +346,6 @@ use smithy.test#httpResponseTests }, code: 200, bodyMediaType: "application/cbor", - // http://ec2-54-84-9-83.compute-1.amazonaws.com/hex?value=v2tkb3VibGVWYWx1Zfk%2BAGpmbG9hdFZhbHVl%2BUegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8%3D body: "v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=" params: { doubleValue: 1.5, From a77b079fc295be4929f5e7ef97a743b4df55b64f Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Fri, 22 Mar 2024 21:32:26 +0000 Subject: [PATCH 25/30] Add ValidationException to RpcV2CborSparseMaps --- smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy | 1 + 1 file changed, 1 insertion(+) diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy index d0b502b36c8..68e6c594fd9 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy @@ -435,6 +435,7 @@ apply RpcV2CborSparseMaps @httpResponseTests([ operation RpcV2CborSparseMaps { input: RpcV2CborSparseMapsInputOutput output: RpcV2CborSparseMapsInputOutput + errors: [ValidationException] } structure RpcV2CborSparseMapsInputOutput { From d34834ddf103f1535007783d89106775fae93037 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Fri, 22 Mar 2024 15:07:43 -0700 Subject: [PATCH 26/30] Create smithy-protocol-tests for rpcv2Cbor tests --- settings.gradle | 1 + .../model/shared-types.smithy | 4 - smithy-protocol-tests/build.gradle | 28 +++ .../model/rpcv2Cbor}/cbor-lists.smithy | 24 +- .../model/rpcv2Cbor}/cbor-maps.smithy | 10 +- .../model/rpcv2Cbor}/cbor-structs.smithy | 2 +- .../model/rpcv2Cbor}/defaults.smithy | 2 +- .../rpcv2Cbor}/empty-input-output.smithy | 2 +- .../model/rpcv2Cbor}/errors.smithy | 2 +- .../rpcv2Cbor}/fractional-seconds.smithy | 4 +- .../model/rpcv2Cbor}/main.smithy | 5 +- .../model/shared-types.smithy | 215 ++++++++++++++++++ 12 files changed, 269 insertions(+), 30 deletions(-) create mode 100644 smithy-protocol-tests/build.gradle rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/cbor-lists.smithy (95%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/cbor-maps.smithy (98%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/cbor-structs.smithy (99%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/defaults.smithy (99%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/empty-input-output.smithy (99%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/errors.smithy (98%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/fractional-seconds.smithy (91%) rename {smithy-aws-protocol-tests/model/rpcV2 => smithy-protocol-tests/model/rpcv2Cbor}/main.smithy (86%) create mode 100644 smithy-protocol-tests/model/shared-types.smithy diff --git a/settings.gradle b/settings.gradle index b2b2da0b6b1..9605f4c7e0d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -35,3 +35,4 @@ include ":smithy-syntax" include ":smithy-aws-endpoints" include ":smithy-aws-smoke-test-model" include ":smithy-protocol-traits" +include ":smithy-protocol-tests" diff --git a/smithy-aws-protocol-tests/model/shared-types.smithy b/smithy-aws-protocol-tests/model/shared-types.smithy index 9b282b22959..b4e31ba4d69 100644 --- a/smithy-aws-protocol-tests/model/shared-types.smithy +++ b/smithy-aws-protocol-tests/model/shared-types.smithy @@ -121,10 +121,6 @@ list LongSet { member: Long, } -list TimestampList { - member: Timestamp, -} - @uniqueItems list TimestampSet { member: Timestamp, diff --git a/smithy-protocol-tests/build.gradle b/smithy-protocol-tests/build.gradle new file mode 100644 index 00000000000..fb711a704e4 --- /dev/null +++ b/smithy-protocol-tests/build.gradle @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +plugins { + id "software.amazon.smithy.gradle.smithy-jar" version "$smithyGradleVersion" +} + +description = "Defines protocol tests for Smithy HTTP protocols." + +ext { + displayName = "Smithy :: Protocol Tests" + moduleName = "software.amazon.smithy.protocoltests" +} + +dependencies { + implementation project(path: ":smithy-cli", configuration: "shadow") + implementation project(":smithy-protocol-test-traits") + implementation project(":smithy-protocol-traits") + api project(":smithy-validation-model") +} + +tasks["sourcesJar"].dependsOn("smithyJarStaging") + +smithy { + format.set(false) +} diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy b/smithy-protocol-tests/model/rpcv2Cbor/cbor-lists.smithy similarity index 95% rename from smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/cbor-lists.smithy index 17b85016f46..c87ebb3bbba 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-lists.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/cbor-lists.smithy @@ -2,19 +2,19 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor -use aws.protocoltests.shared#BooleanList -use aws.protocoltests.shared#BlobList -use aws.protocoltests.shared#FooEnumList -use aws.protocoltests.shared#IntegerEnumList -use aws.protocoltests.shared#IntegerList -use aws.protocoltests.shared#NestedStringList -use aws.protocoltests.shared#SparseStringList -use aws.protocoltests.shared#SparseStringMap -use aws.protocoltests.shared#StringList -use aws.protocoltests.shared#StringSet -use aws.protocoltests.shared#TimestampList +use smithy.protocoltests.shared#BooleanList +use smithy.protocoltests.shared#BlobList +use smithy.protocoltests.shared#FooEnumList +use smithy.protocoltests.shared#IntegerEnumList +use smithy.protocoltests.shared#IntegerList +use smithy.protocoltests.shared#NestedStringList +use smithy.protocoltests.shared#SparseStringList +use smithy.protocoltests.shared#SparseStringMap +use smithy.protocoltests.shared#StringList +use smithy.protocoltests.shared#StringSet +use smithy.protocoltests.shared#TimestampList use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests use smithy.test#httpResponseTests diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy b/smithy-protocol-tests/model/rpcv2Cbor/cbor-maps.smithy similarity index 98% rename from smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/cbor-maps.smithy index 68e6c594fd9..ba21ff62a12 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-maps.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/cbor-maps.smithy @@ -1,11 +1,11 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor -use aws.protocoltests.shared#FooEnumMap -use aws.protocoltests.shared#GreetingStruct -use aws.protocoltests.shared#SparseStringMap -use aws.protocoltests.shared#StringSet +use smithy.protocoltests.shared#FooEnumMap +use smithy.protocoltests.shared#GreetingStruct +use smithy.protocoltests.shared#SparseStringMap +use smithy.protocoltests.shared#StringSet use smithy.test#httpRequestTests use smithy.test#httpResponseTests use smithy.protocols#rpcv2Cbor diff --git a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy b/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy similarity index 99% rename from smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy index 3e88a0564d3..b6c8b099b63 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/cbor-structs.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy @@ -1,6 +1,6 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests diff --git a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy b/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy similarity index 99% rename from smithy-aws-protocol-tests/model/rpcV2/defaults.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy index df22203db9c..06628dbc04c 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/defaults.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy @@ -1,6 +1,6 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests diff --git a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy b/smithy-protocol-tests/model/rpcv2Cbor/empty-input-output.smithy similarity index 99% rename from smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/empty-input-output.smithy index 6635fe7237c..f178b9ee0b3 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/empty-input-output.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/empty-input-output.smithy @@ -1,6 +1,6 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests diff --git a/smithy-aws-protocol-tests/model/rpcV2/errors.smithy b/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy similarity index 98% rename from smithy-aws-protocol-tests/model/rpcV2/errors.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/errors.smithy index 0fbaf3f6eae..709efb308de 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/errors.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy @@ -1,6 +1,6 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor use smithy.test#httpRequestTests use smithy.test#httpResponseTests diff --git a/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy b/smithy-protocol-tests/model/rpcv2Cbor/fractional-seconds.smithy similarity index 91% rename from smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/fractional-seconds.smithy index 5fc19157a73..faad52e9015 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/fractional-seconds.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/fractional-seconds.smithy @@ -1,9 +1,9 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor +namespace smithy.protocoltests.rpcv2Cbor use smithy.protocols#rpcv2Cbor -use aws.protocoltests.shared#DateTime +use smithy.protocoltests.shared#DateTime use smithy.test#httpResponseTests // These tests verify that clients can parse `DateTime` timestamps with fractional seconds. diff --git a/smithy-aws-protocol-tests/model/rpcV2/main.smithy b/smithy-protocol-tests/model/rpcv2Cbor/main.smithy similarity index 86% rename from smithy-aws-protocol-tests/model/rpcV2/main.smithy rename to smithy-protocol-tests/model/rpcv2Cbor/main.smithy index afe2794f79c..9d10e723e56 100644 --- a/smithy-aws-protocol-tests/model/rpcV2/main.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/main.smithy @@ -1,12 +1,11 @@ $version: "2.0" -namespace aws.protocoltests.rpcv2Cbor -use aws.api#service +namespace smithy.protocoltests.rpcv2Cbor + use smithy.protocols#rpcv2Cbor use smithy.test#httpRequestTests use smithy.test#httpResponseTests -@service(sdkId: "Sample RpcV2 Protocol") @rpcv2Cbor @title("RpcV2 Protocol Service") service RpcV2Protocol { diff --git a/smithy-protocol-tests/model/shared-types.smithy b/smithy-protocol-tests/model/shared-types.smithy new file mode 100644 index 00000000000..5340018ccd6 --- /dev/null +++ b/smithy-protocol-tests/model/shared-types.smithy @@ -0,0 +1,215 @@ +// This file contains shared types that are used throughout the test cases. +// +// Anything that is generic enough that it could potentially be reused +// should be defined in this file. However, things like input or output +// structures or other test-case specific shapes should be defined closer to +// the test case and in its same file. + +$version: "2.0" + +namespace smithy.protocoltests.shared + +list StringList { + member: String, +} + +@sparse +list SparseStringList { + member: String +} + +@uniqueItems +list StringSet { + member: String, +} + +map StringMap { + key: String, + value: String, +} + +map StringListMap { + key: String, + value: StringList +} + +@sparse +map SparseStringMap { + key: String, + value: String, +} + +/// A list of lists of strings. +list NestedStringList { + member: StringList, +} + +list ShortList { + member: Short, +} + +list IntegerList { + member: Integer, +} + +@uniqueItems +list IntegerSet { + member: Integer, +} + +list FloatList { + member: Float, +} + +list DoubleList { + member: Double, +} + +list BooleanList { + member: Boolean, +} + +@uniqueItems +list BooleanSet { + member: Boolean, +} + +list TimestampList { + member: Timestamp, +} + +list BlobList { + member: Blob, +} + +@uniqueItems +list BlobSet { + member: Blob, +} + +list ByteList { + member: Byte, +} + +@uniqueItems +list ByteSet { + member: Byte, +} +@uniqueItems +list ShortSet { + member: Short, +} + +@uniqueItems +list LongList { + member: Long, +} + +@uniqueItems +list LongSet { + member: Long, +} + +@uniqueItems +list TimestampSet { + member: Timestamp, +} + +list DateTimeList { + member: DateTime, +} + +@uniqueItems +list DateTimeSet { + member: DateTime, +} + +@uniqueItems +list HttpDateSet { + member: HttpDate, +} + +@uniqueItems +list ListSet { + member: StringList +} + +@uniqueItems +list StructureSet { + member: GreetingStruct +} + +@uniqueItems +list UnionSet { + member: FooUnion +} + +union FooUnion { + string: String + integer: Integer +} + +enum FooEnum { + FOO = "Foo" + BAZ = "Baz" + BAR = "Bar" + ONE = "1" + ZERO = "0" +} + +list FooEnumList { + member: FooEnum, +} + +@uniqueItems +list FooEnumSet { + member: FooEnum, +} + +map FooEnumMap { + key: String, + value: FooEnum, +} + +@timestampFormat("date-time") +timestamp DateTime + +@timestampFormat("epoch-seconds") +timestamp EpochSeconds + +@timestampFormat("http-date") +timestamp HttpDate + +@mediaType("text/plain") +blob TextPlainBlob + +@mediaType("image/jpeg") +blob JpegBlob + +structure GreetingStruct { + hi: String +} + +list GreetingList { + member: GreetingStruct +} + +intEnum IntegerEnum { + A = 1 + B = 2 + C = 3 +} + +list IntegerEnumList { + member: IntegerEnum +} + +@uniqueItems +list IntegerEnumSet { + member: IntegerEnum +} + +map IntegerEnumMap { + key: String, + value: IntegerEnum +} From 4e0504082596001f2310cb20b83ab45ca878f27f Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Sun, 24 Mar 2024 21:59:46 -0700 Subject: [PATCH 27/30] Fix rpcv2Cbor defaults test uris --- .../model/rpcv2Cbor/defaults.smithy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy b/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy index 06628dbc04c..8d22964423d 100644 --- a/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/defaults.smithy @@ -15,7 +15,7 @@ apply OperationWithDefaults @httpRequestTests([ appliesTo: "client" tags: ["defaults"] method: "POST" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -35,7 +35,7 @@ apply OperationWithDefaults @httpRequestTests([ protocol: rpcv2Cbor method: "POST" bodyMediaType: "application/cbor" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -53,7 +53,7 @@ apply OperationWithDefaults @httpRequestTests([ protocol: rpcv2Cbor method: "POST" bodyMediaType: "application/cbor" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -96,7 +96,7 @@ apply OperationWithDefaults @httpRequestTests([ protocol: rpcv2Cbor method: "POST" bodyMediaType: "application/cbor" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -141,7 +141,7 @@ apply OperationWithDefaults @httpRequestTests([ protocol: rpcv2Cbor method: "POST" bodyMediaType: "application/cbor" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", @@ -161,7 +161,7 @@ apply OperationWithDefaults @httpRequestTests([ protocol: rpcv2Cbor method: "POST" bodyMediaType: "application/cbor" - uri: "/" + uri: "/service/RpcV2Protocol/operation/OperationWithDefaults", headers: { "smithy-protocol": "rpc-v2-cbor", "Accept": "application/cbor", From 2a4b7db7435da875a49f423d7d0ee75937a12fb5 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Sun, 24 Mar 2024 22:05:07 -0700 Subject: [PATCH 28/30] Add tests for skipping extra fields --- .../model/rpcv2Cbor/cbor-structs.smithy | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy b/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy index b6c8b099b63..effaefc0016 100644 --- a/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/cbor-structs.smithy @@ -209,6 +209,36 @@ use smithy.test#httpResponseTests }, appliesTo: "server" }, + { + id: "RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers", + protocol: rpcv2Cbor, + documentation: """ + The server should skip over additional fields that are not part of the structure. This allows a + client generated against a newer Smithy model to be able to communicate with a server that is + generated against an older Smithy model.""", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Accept": "application/cbor", + "Content-Type": "application/cbor" + } + method: "POST", + bodyMediaType: "application/cbor", + uri: "/service/RpcV2Protocol/operation/SimpleScalarProperties", + body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989rZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==", + params: { + byteValue: 5, + doubleValue: 1.889, + falseBooleanValue: false, + floatValue: 7.624, + integerValue: 256, + longValue: 9873, + shortValue: 9898, + stringValue: "simple", + trueBooleanValue: true, + blobValue: "foo" + }, + appliesTo: "server" + } ]) @httpResponseTests([ { @@ -336,7 +366,7 @@ use smithy.test#httpResponseTests floatValue: "-Infinity" } }, - { + { id: "RpcV2CborSupportsUpcastingDataOnDeserialize", protocol: rpcv2Cbor, documentation: "Supports upcasting from a smaller byte representation of the same data type.", @@ -356,6 +386,34 @@ use smithy.test#httpResponseTests }, appliesTo: "client" }, + { + id: "RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByClients", + protocol: rpcv2Cbor, + documentation: """ + The client should skip over additional fields that are not part of the structure. This allows a + client generated against an older Smithy model to be able to communicate with a server that is + generated against a newer Smithy model.""", + headers: { + "smithy-protocol": "rpc-v2-cbor", + "Content-Type": "application/cbor" + } + code: 200, + bodyMediaType: "application/cbor", + body: "v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kDz989rZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==", + params: { + byteValue: 5, + doubleValue: 1.889, + falseBooleanValue: false, + floatValue: 7.624, + integerValue: 256, + longValue: 9873, + shortValue: 9898, + stringValue: "simple", + trueBooleanValue: true, + blobValue: "foo" + }, + appliesTo: "client" + } ]) operation SimpleScalarProperties { input: SimpleScalarStructure, From 88fdc80ae58f721bd20e567a2870016d5d26e58f Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Mon, 25 Mar 2024 09:10:42 -0700 Subject: [PATCH 29/30] Fix error namespaces after package move --- smithy-protocol-tests/model/rpcv2Cbor/errors.smithy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy b/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy index 709efb308de..d9f0c17832d 100644 --- a/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy +++ b/smithy-protocol-tests/model/rpcv2Cbor/errors.smithy @@ -43,7 +43,7 @@ apply InvalidGreeting @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4K2F3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", + body: "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", bodyMediaType: "application/cbor", }, ]) @@ -75,7 +75,7 @@ apply ComplexError @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4KGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", + body: "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", bodyMediaType: "application/cbor" }, { @@ -86,7 +86,7 @@ apply ComplexError @httpResponseTests([ "smithy-protocol": "rpc-v2-cbor", "Content-Type": "application/cbor" }, - body: "v2ZfX3R5cGV4KGF3cy5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/", + body: "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/", bodyMediaType: "application/cbor" }, ]) From 4ca33091cc9d60fb1a8b4af74086989f9011540b Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Mon, 25 Mar 2024 09:11:50 -0700 Subject: [PATCH 30/30] Remove RPCv2 CI config --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f86ffc8a63c..de2607dbab2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: ci on: push: - branches: [main, smithy-rpc-v2] + branches: [main] pull_request: - branches: [main, smithy-rpc-v2] + branches: [main] jobs: build: