From 8686bc3b6b7a857fe29f09627379686e207d8147 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:28:11 +0000 Subject: [PATCH 1/6] chore(codegen): bump smithy to 1.15.x --- codegen/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/build.gradle.kts b/codegen/build.gradle.kts index f9ed72501bf9..2ba03538d267 100644 --- a/codegen/build.gradle.kts +++ b/codegen/build.gradle.kts @@ -31,7 +31,7 @@ allprojects { version = "0.8.0" } -extra["smithyVersion"] = "[1.14.0,1.15.0[" +extra["smithyVersion"] = "[1.15.0,1.16.0[" // The root project doesn't produce a JAR. tasks["jar"].enabled = false From 026515384947fde376dbada364ffe3ef3c1d6e93 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:32:08 +0000 Subject: [PATCH 2/6] chore(clients): yarn generate-clients --- .../test/functional/restjson1.spec.ts | 73 ++++++++++++++++++- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index b07e5c806ad4..c8e22282c57e 100644 --- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts @@ -2957,6 +2957,38 @@ it("RestJsonInputAndOutputWithStringHeaders:Request", async () => { } }); +/** + * Tests requests with string list header bindings that require quoting + */ +it("RestJsonInputAndOutputWithQuotedStringHeaders:Request", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new RequestSerializationTestHandler(), + }); + + const command = new InputAndOutputWithHeadersCommand({ + headerStringList: ["b,c", '"def"', "a"], + } as any); + try { + await client.send(command); + fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown"); + return; + } catch (err) { + if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) { + fail(err); + return; + } + const r = err.request; + expect(r.method).toBe("POST"); + expect(r.path).toBe("/InputAndOutputWithHeaders"); + + expect(r.headers["x-stringlist"]).toBeDefined(); + expect(r.headers["x-stringlist"]).toBe('"b,c",""def"",a'); + + expect(r.body).toBeFalsy(); + } +}); + /** * Tests requests with numeric header bindings */ @@ -3085,7 +3117,7 @@ it("RestJsonInputAndOutputWithTimestampHeaders:Request", async () => { expect(r.path).toBe("/InputAndOutputWithHeaders"); expect(r.headers["x-timestamplist"]).toBeDefined(); - expect(r.headers["x-timestamplist"]).toBe("Mon, 16 Dec 2019 23:48:18 GMT, Mon, 16 Dec 2019 23:48:18 GMT"); + expect(r.headers["x-timestamplist"]).toBe('"Mon, 16 Dec 2019 23:48:18 GMT", "Mon, 16 Dec 2019 23:48:18 GMT"'); expect(r.body).toBeFalsy(); } @@ -3274,6 +3306,39 @@ it("RestJsonInputAndOutputWithStringHeaders:Response", async () => { }); }); +/** + * Tests responses with string list header bindings that require quoting + */ +it("RestJsonInputAndOutputWithQuotedStringHeaders:Response", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler(true, 200, { + "x-stringlist": '"b,c",""def"",a', + }), + }); + + const params: any = {}; + const command = new InputAndOutputWithHeadersCommand(params); + + let r: any; + try { + r = await client.send(command); + } catch (err) { + fail("Expected a valid response to be returned, got err."); + return; + } + expect(r["$metadata"].httpStatusCode).toBe(200); + const paramsToValidate: any = [ + { + headerStringList: ["a", "b,c", '"def"'], + }, + ][0]; + Object.keys(paramsToValidate).forEach((param) => { + expect(r[param]).toBeDefined(); + expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true); + }); +}); + /** * Tests responses with numeric header bindings */ @@ -3377,7 +3442,7 @@ it("RestJsonInputAndOutputWithTimestampHeaders:Response", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler(true, 200, { - "x-timestamplist": "Mon, 16 Dec 2019 23:48:18 GMT, Mon, 16 Dec 2019 23:48:18 GMT", + "x-timestamplist": '"Mon, 16 Dec 2019 23:48:18 GMT", "Mon, 16 Dec 2019 23:48:18 GMT"', }), }); @@ -7722,8 +7787,6 @@ it.skip("RestJsonTestPayloadStructure:Request", async () => { }); const command = new TestPayloadStructureCommand({ - testId: "t-12345", - payloadConfig: { data: 25, } as any, @@ -7782,6 +7845,8 @@ it.skip("RestJsonHttpWithHeadersButNoPayload:Request", async () => { expect(r.headers["content-type"]).toBeDefined(); expect(r.headers["content-type"]).toBe("application/json"); + expect(r.headers["x-amz-test-id"]).toBeDefined(); + expect(r.headers["x-amz-test-id"]).toBe("t-12345"); expect(r.body).toBeDefined(); const utf8Encoder = client.config.utf8Encoder; From 4960f0f97bfbe7ade71e9fdce4e589e2c71172c0 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:42:40 +0000 Subject: [PATCH 3/6] chore(codegen): skip RestJsonInputAndOutputWithQuotedStringHeaders --- .../smithy/aws/typescript/codegen/AwsProtocolUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java index 7fef8373e34d..649e7690ad7f 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java @@ -298,6 +298,7 @@ private static boolean filterProtocolTests( if (testCase.getId().equals("QueryCustomizedError")) { return true; } + // TODO: Remove when server protocol tests are fixed in // https://github.com/aws/aws-sdk-js-v3/issues/3058 // TODO: Move to filter specific to server protocol tests if added in @@ -306,6 +307,13 @@ private static boolean filterProtocolTests( || testCase.getId().equals("RestJsonHttpWithHeadersButNoPayload")) { return true; } + + // TODO: remove when there's a decision on separator to use + // https://github.com/awslabs/smithy/issues/1014 + if (testCase.getId().equals("RestJsonInputAndOutputWithQuotedStringHeaders")) { + return true; + } + return false; } From af9ff070bded4a7d49464c005c629f4da4a4f5a5 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:44:55 +0000 Subject: [PATCH 4/6] chore(aws-protocoltests-restjson): skip RestJsonInputAndOutputWithQuotedStringHeaders --- .../test/functional/restjson1.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index c8e22282c57e..96d593825171 100644 --- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts @@ -2960,7 +2960,7 @@ it("RestJsonInputAndOutputWithStringHeaders:Request", async () => { /** * Tests requests with string list header bindings that require quoting */ -it("RestJsonInputAndOutputWithQuotedStringHeaders:Request", async () => { +it.skip("RestJsonInputAndOutputWithQuotedStringHeaders:Request", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new RequestSerializationTestHandler(), @@ -3309,7 +3309,7 @@ it("RestJsonInputAndOutputWithStringHeaders:Response", async () => { /** * Tests responses with string list header bindings that require quoting */ -it("RestJsonInputAndOutputWithQuotedStringHeaders:Response", async () => { +it.skip("RestJsonInputAndOutputWithQuotedStringHeaders:Response", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler(true, 200, { From 279a3ff3aa3d6bfaf02c5a7555741d14062269ed Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 22:36:16 +0000 Subject: [PATCH 5/6] chore(aws-protocoltests-restjson): skip RestJsonInputAndOutputWithTimestampHeaders --- .../smithy/aws/typescript/codegen/AwsProtocolUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java index 649e7690ad7f..7ef62972c78a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java @@ -314,6 +314,12 @@ private static boolean filterProtocolTests( return true; } + // TODO: remove when there's a decision on behavior for list of timestamps. + // https://github.com/awslabs/smithy/issues/1015 + if (testCase.getId().equals("RestJsonInputAndOutputWithTimestampHeaders")) { + return true; + } + return false; } From 0d9d93f1719cc10cbb31bfd1be37b9bc09377347 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 10 Dec 2021 22:38:12 +0000 Subject: [PATCH 6/6] test(aws-protocoltests-restjson): skip RestJsonInputAndOutputWithTimestampHeaders --- .../test/functional/restjson1.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index 96d593825171..7f51079f529a 100644 --- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts @@ -3094,7 +3094,7 @@ it("RestJsonInputAndOutputWithBooleanHeaders:Request", async () => { /** * Tests requests with timestamp header bindings */ -it("RestJsonInputAndOutputWithTimestampHeaders:Request", async () => { +it.skip("RestJsonInputAndOutputWithTimestampHeaders:Request", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new RequestSerializationTestHandler(), @@ -3438,7 +3438,7 @@ it("RestJsonInputAndOutputWithBooleanHeaders:Response", async () => { /** * Tests responses with timestamp header bindings */ -it("RestJsonInputAndOutputWithTimestampHeaders:Response", async () => { +it.skip("RestJsonInputAndOutputWithTimestampHeaders:Response", async () => { const client = new RestJsonProtocolClient({ ...clientParams, requestHandler: new ResponseDeserializationTestHandler(true, 200, {