Skip to content

Commit

Permalink
test: enable protocol tests blocked by previous versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 26, 2024
1 parent b92df20 commit 9ccd34e
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,44 +305,17 @@ private static boolean filterProtocolTests(
HttpMessageTestCase testCase,
TypeScriptSettings settings
) {
// TODO: Remove when requestCompression has been implemented.
if (testCase.getId().startsWith("SDKAppliedContentEncoding_")
|| testCase.getId().startsWith("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_")
|| testCase.getId().startsWith("SDKAppendedGzipAfterProvidedEncoding_")) {
return true;
}

// TODO: Remove when upstream tests update to serialize empty headers.
if (testCase.getId().contains("NullAndEmptyHeaders")) {
return true;
}

if (testCase.getTags().contains("defaults")) {
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: implementation change pending.
List<String> extraUnionKey = Arrays.asList(
"RestXmlHttpPayloadWithUnsetUnion",
"RestJsonHttpPayloadWithUnsetUnion"
);
if (extraUnionKey.contains(testCase.getId())) {
return true;
}

// TODO: remove when Glacier AccountID hyphen customization is implemented: SMITHY-2614
if (testCase.getId().equals("GlacierAccountId")) {
return true;
}

// ToDo: https://github.com/aws/aws-sdk-js-v3/issues/6246
if (testCase.getId().equals("RestJsonMustSupportParametersInContentType")) {
if (testCase.getTags().contains("defaults")) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ it("Ec2QueryNoInputAndOutput:Response", async () => {
/**
* Compression algorithm encoding is appended to the Content-Encoding header.
*/
it.skip("SDKAppliedContentEncoding_ec2Query:Request", async () => {
it("SDKAppliedContentEncoding_ec2Query:Request", async () => {
const client = new EC2ProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down Expand Up @@ -868,7 +868,7 @@ it.skip("SDKAppliedContentEncoding_ec2Query:Request", async () => {
* traits are ignored in the ec2Query protocol.
*
*/
it.skip("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query:Request", async () => {
it("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query:Request", async () => {
const client = new EC2ProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2751,7 +2751,7 @@ it.skip("AwsJson10ClientErrorCorrectsWhenServerFailsToSerializeRequiredValues:Re
/**
* Compression algorithm encoding is appended to the Content-Encoding header.
*/
it.skip("SDKAppliedContentEncoding_awsJson1_0:Request", async () => {
it("SDKAppliedContentEncoding_awsJson1_0:Request", async () => {
const client = new JSONRPC10Client({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down Expand Up @@ -2784,7 +2784,7 @@ it.skip("SDKAppliedContentEncoding_awsJson1_0:Request", async () => {
* traits are ignored in the awsJson1_0 protocol.
*
*/
it.skip("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0:Request", async () => {
it("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0:Request", async () => {
const client = new JSONRPC10Client({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4410,7 +4410,7 @@ it("PutAndGetInlineDocumentsInput:Response", async () => {
/**
* Compression algorithm encoding is appended to the Content-Encoding header.
*/
it.skip("SDKAppliedContentEncoding_awsJson1_1:Request", async () => {
it("SDKAppliedContentEncoding_awsJson1_1:Request", async () => {
const client = new JsonProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down Expand Up @@ -4443,7 +4443,7 @@ it.skip("SDKAppliedContentEncoding_awsJson1_1:Request", async () => {
* traits are ignored in the awsJson1_1 protocol.
*
*/
it.skip("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1:Request", async () => {
it("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1:Request", async () => {
const client = new JsonProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ it("QueryNoInputAndOutput:Response", async () => {
/**
* Compression algorithm encoding is appended to the Content-Encoding header.
*/
it.skip("SDKAppliedContentEncoding_awsQuery:Request", async () => {
it("SDKAppliedContentEncoding_awsQuery:Request", async () => {
const client = new QueryProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down Expand Up @@ -1121,7 +1121,7 @@ it.skip("SDKAppliedContentEncoding_awsQuery:Request", async () => {
* traits are ignored in the awsQuery protocol.
*
*/
it.skip("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery:Request", async () => {
it("SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery:Request", async () => {
const client = new QueryProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ it("ApiGatewayAccept:Request", async () => {
expect(r.headers["accept"]).toBeDefined();
expect(r.headers["accept"]).toBe("application/json");

expect(r.body).toBeFalsy();
expect(!r.body || r.body === `{}`).toBeTruthy();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ it("GlacierVersionHeader:Request", async () => {
expect(r.headers["x-amz-glacier-version"]).toBeDefined();
expect(r.headers["x-amz-glacier-version"]).toBe("2012-06-01");

expect(r.body).toBeFalsy();
expect(!r.body || r.body === `{}`).toBeTruthy();
}
});

Expand Down Expand Up @@ -311,7 +311,7 @@ it.skip("GlacierAccountId:Request", async () => {
expect(r.headers["x-amz-glacier-version"]).toBeDefined();
expect(r.headers["x-amz-glacier-version"]).toBe("2012-06-01");

expect(r.body).toBeFalsy();
expect(!r.body || r.body === `{}`).toBeTruthy();
}
});

Expand Down
17 changes: 10 additions & 7 deletions private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
parseEpochTimestamp as __parseEpochTimestamp,
parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset,
parseRfc7231DateTime as __parseRfc7231DateTime,
quoteHeader as __quoteHeader,
resolvedPath as __resolvedPath,
serializeDateTime as __serializeDateTime,
serializeFloat as __serializeFloat,
Expand Down Expand Up @@ -1033,8 +1034,8 @@ export const se_InputAndOutputWithHeadersCommand = async (
],
[_xb_]: [() => isSerializableHeaderValue(input[_hTB]), () => input[_hTB]!.toString()],
[_xb__]: [() => isSerializableHeaderValue(input[_hFB]), () => input[_hFB]!.toString()],
[_xs__]: [() => isSerializableHeaderValue(input[_hSL]), () => (input[_hSL]! || []).join(", ")],
[_xs___]: [() => isSerializableHeaderValue(input[_hSS]), () => (input[_hSS]! || []).join(", ")],
[_xs__]: [() => isSerializableHeaderValue(input[_hSL]), () => (input[_hSL]! || []).map(__quoteHeader).join(", ")],
[_xs___]: [() => isSerializableHeaderValue(input[_hSS]), () => (input[_hSS]! || []).map(__quoteHeader).join(", ")],
[_xi_]: [
() => isSerializableHeaderValue(input[_hIL]),
() => (input[_hIL]! || []).map((_entry) => _entry.toString() as any).join(", "),
Expand All @@ -1048,7 +1049,7 @@ export const se_InputAndOutputWithHeadersCommand = async (
() => (input[_hTL]! || []).map((_entry) => __dateToUtcString(_entry).toString() as any).join(", "),
],
[_xe]: input[_hE]!,
[_xe_]: [() => isSerializableHeaderValue(input[_hEL]), () => (input[_hEL]! || []).join(", ")],
[_xe_]: [() => isSerializableHeaderValue(input[_hEL]), () => (input[_hEL]! || []).map(__quoteHeader).join(", ")],
[_xi__]: [() => isSerializableHeaderValue(input[_hIE]), () => input[_hIE]!.toString()],
[_xi___]: [
() => isSerializableHeaderValue(input[_hIEL]),
Expand Down Expand Up @@ -1987,7 +1988,7 @@ export const se_NullAndEmptyHeadersClientCommand = async (
const headers: any = map({}, isSerializableHeaderValue, {
[_xa]: input[_a]!,
[_xb____]: input[_b_]!,
[_xc]: [() => isSerializableHeaderValue(input[_c]), () => (input[_c]! || []).join(", ")],
[_xc]: [() => isSerializableHeaderValue(input[_c]), () => (input[_c]! || []).map(__quoteHeader).join(", ")],
});
b.bp("/NullAndEmptyHeadersClient");
let body: any;
Expand All @@ -2006,7 +2007,7 @@ export const se_NullAndEmptyHeadersServerCommand = async (
const headers: any = map({}, isSerializableHeaderValue, {
[_xa]: input[_a]!,
[_xb____]: input[_b_]!,
[_xc]: [() => isSerializableHeaderValue(input[_c]), () => (input[_c]! || []).join(", ")],
[_xc]: [() => isSerializableHeaderValue(input[_c]), () => (input[_c]! || []).map(__quoteHeader).join(", ")],
});
b.bp("/NullAndEmptyHeadersServer");
let body: any;
Expand Down Expand Up @@ -2910,8 +2911,10 @@ export const de_HttpPayloadWithUnionCommand = async (
const contents: any = map({
$metadata: deserializeMetadata(output),
});
const data: Record<string, any> | undefined = __expectUnion(await parseBody(output.body, context));
contents.nested = _json(data);
const data: Record<string, any> | undefined = await parseBody(output.body, context);
if (Object.keys(data ?? {}).length) {
contents.nested = __expectUnion(_json(data));
}
return contents;
};

Expand Down
Loading

0 comments on commit 9ccd34e

Please sign in to comment.