diff --git a/codegen/build.gradle.kts b/codegen/build.gradle.kts index f9ed72501bf97..2ba03538d2671 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 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 7fef8373e34d7..7ef62972c78a0 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,19 @@ 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; + } + + // 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; } diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index b07e5c806ad47..7f51079f529a9 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.skip("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 */ @@ -3062,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(), @@ -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.skip("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 */ @@ -3373,11 +3438,11 @@ 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, { - "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;