Skip to content

chore(codegen): pin smithy to 1.8.x #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/protocol-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
}

dependencies {
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.7.0, 1.8.0[")
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.8.0, 1.9.0[")
compile(project(":smithy-aws-typescript-codegen"))
}

Expand Down
8 changes: 4 additions & 4 deletions codegen/smithy-aws-typescript-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extra["displayName"] = "Smithy :: AWS :: Typescript :: Codegen"
extra["moduleName"] = "software.amazon.smithy.aws.typescript.codegen"

dependencies {
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.7.0, 1.8.0[")
api("software.amazon.smithy:smithy-aws-traits:[1.7.0, 1.8.0[")
api("software.amazon.smithy:smithy-waiters:[1.7.0, 1.8.0[")
api("software.amazon.smithy:smithy-aws-iam-traits:[1.7.0, 1.8.0[")
api("software.amazon.smithy:smithy-aws-cloudformation-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-aws-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-waiters:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-aws-iam-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy.typescript:smithy-typescript-codegen:0.3.0")
}
15 changes: 15 additions & 0 deletions protocol_tests/aws-query/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ export namespace ComplexError {
});
}

export interface CustomCodeError extends __SmithyException, $MetadataBearer {
name: "CustomCodeError";
$fault: "client";
Message?: string;
}

export namespace CustomCodeError {
/**
* @internal
*/
export const filterSensitiveLog = (obj: CustomCodeError): any => ({
...obj,
});
}

export interface GreetingWithErrorsOutput {
greeting?: string;
}
Expand Down
34 changes: 34 additions & 0 deletions protocol_tests/aws-query/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { XmlTimestampsCommandInput, XmlTimestampsCommandOutput } from "../comman
import {
ComplexError,
ComplexNestedErrorData,
CustomCodeError,
EmptyInputAndEmptyOutputInput,
EmptyInputAndEmptyOutputOutput,
FlattenedXmlMapOutput,
Expand Down Expand Up @@ -843,6 +844,14 @@ const deserializeAws_queryGreetingWithErrorsCommandError = async (
$metadata: deserializeMetadata(output),
};
break;
case "CustomCodeError":
case "aws.protocoltests.query#CustomCodeError":
response = {
...(await deserializeAws_queryCustomCodeErrorResponse(parsedOutput, context)),
name: errorCode,
$metadata: deserializeMetadata(output),
};
break;
case "InvalidGreeting":
case "aws.protocoltests.query#InvalidGreeting":
response = {
Expand Down Expand Up @@ -1825,6 +1834,21 @@ const deserializeAws_queryComplexErrorResponse = async (
return contents;
};

const deserializeAws_queryCustomCodeErrorResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<CustomCodeError> => {
const body = parsedOutput.body;
const deserialized: any = deserializeAws_queryCustomCodeError(body.Error, context);
const contents: CustomCodeError = {
name: "CustomCodeError",
$fault: "client",
$metadata: deserializeMetadata(parsedOutput),
...deserialized,
};
return contents;
};

const deserializeAws_queryInvalidGreetingResponse = async (
parsedOutput: any,
context: __SerdeContext
Expand Down Expand Up @@ -2171,6 +2195,16 @@ const deserializeAws_queryComplexNestedErrorData = (output: any, context: __Serd
return contents;
};

const deserializeAws_queryCustomCodeError = (output: any, context: __SerdeContext): CustomCodeError => {
let contents: any = {
Message: undefined,
};
if (output["Message"] !== undefined) {
contents.Message = output["Message"];
}
return contents;
};

const deserializeAws_queryEmptyInputAndEmptyOutputOutput = (
output: any,
context: __SerdeContext
Expand Down
59 changes: 56 additions & 3 deletions protocol_tests/aws-query/tests/functional/awsquery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { XmlMapsCommand } from "../../commands/XmlMapsCommand";
import { XmlMapsXmlNameCommand } from "../../commands/XmlMapsXmlNameCommand";
import { XmlNamespacesCommand } from "../../commands/XmlNamespacesCommand";
import { XmlTimestampsCommand } from "../../commands/XmlTimestampsCommand";
import { ComplexError, InvalidGreeting } from "../../models/models_0";
import { ComplexError, CustomCodeError, InvalidGreeting } from "../../models/models_0";
import { HttpHandlerOptions, HeaderBag } from "@aws-sdk/types";
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import { Readable } from "stream";
Expand Down Expand Up @@ -545,6 +545,59 @@ it("QueryInvalidGreetingError:Error:GreetingWithErrors", async () => {
fail("Expected an exception to be thrown from response");
});

/**
* Parses customized XML errors
*/
// Manually skipping to unblock smithy-1.8.x update.
// TODO: Consume AWSQueryError trait as a follow-up.
it.skip("QueryCustomizedError:Error:GreetingWithErrors", async () => {
const client = new QueryProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
false,
402,
{
"content-type": "text/xml",
},
`<ErrorResponse>
<Error>
<Type>Sender</Type>
<Code>Customized</Code>
<Message>Hi</Message>
</Error>
<RequestId>foo-id</RequestId>
</ErrorResponse>
`
),
});

const params: any = {};
const command = new GreetingWithErrorsCommand(params);

try {
await client.send(command);
} catch (err) {
if (err.name !== "CustomCodeError") {
console.log(err);
fail(`Expected a CustomCodeError to be thrown, got ${err.name} instead`);
return;
}
const r: any = err;
expect(r["$metadata"].httpStatusCode).toBe(402);
const paramsToValidate: any = [
{
message: "Hi",
},
][0];
Object.keys(paramsToValidate).forEach((param) => {
expect(r[param]).toBeDefined();
expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true);
});
return;
}
fail("Expected an exception to be thrown from response");
});

it("QueryComplexError:Error:GreetingWithErrors", async () => {
const client = new QueryProtocolClient({
...clientParams,
Expand Down Expand Up @@ -613,7 +666,7 @@ it("QueryIgnoresWrappingXmlName:Response", async () => {
{
"content-type": "text/xml",
},
`<IgnoresWrappingXmlNameResponse xmlns="http://foo.com" xmlns="https://example.com/">
`<IgnoresWrappingXmlNameResponse xmlns="https://example.com/">
<IgnoresWrappingXmlNameResult>
<foo>bar</foo>
</IgnoresWrappingXmlNameResult>
Expand Down Expand Up @@ -2528,7 +2581,7 @@ it("QueryXmlNamespaces:Response", async () => {
{
"content-type": "text/xml",
},
`<XmlNamespacesResponse xmlns="http://foo.com" xmlns="https://example.com/">
`<XmlNamespacesResponse xmlns="https://example.com/">
<XmlNamespacesResult>
<nested>
<foo xmlns:baz="http://baz.com">Foo</foo>
Expand Down
81 changes: 79 additions & 2 deletions protocol_tests/aws-restjson/tests/functional/restjson1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,38 @@ it("RestJsonQueryStringMap:Request", async () => {
}
});

/**
* Handles escaping all required characters in the query string.
*/
it("RestJsonQueryStringEscaping:Request", async () => {
const client = new RestJsonProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
});

const command = new AllQueryStringTypesCommand({
queryString: "%:/?#[]@!$&'()*+,;=😹",
} 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("GET");
expect(r.path).toBe("/AllQueryStringTypesInput");

const queryString = buildQueryString(r.query);
expect(queryString).toContain("String=%25%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%F0%9F%98%B9");

expect(r.body).toBeFalsy();
}
});

/**
* Mixes constant and variable query string parameters
*/
Expand Down Expand Up @@ -1649,7 +1681,7 @@ it("RestJsonHttpRequestWithGreedyLabelInPath:Request", async () => {
});

const command = new HttpRequestWithGreedyLabelInPathCommand({
foo: "hello",
foo: "hello/escape",

baz: "there/guy",
} as any);
Expand All @@ -1664,7 +1696,7 @@ it("RestJsonHttpRequestWithGreedyLabelInPath:Request", async () => {
}
const r = err.request;
expect(r.method).toBe("GET");
expect(r.path).toBe("/HttpRequestWithGreedyLabelInPath/foo/hello/baz/there/guy");
expect(r.path).toBe("/HttpRequestWithGreedyLabelInPath/foo/hello%2Fescape/baz/there/guy");

expect(r.body).toBeFalsy();
}
Expand Down Expand Up @@ -1713,6 +1745,51 @@ it("RestJsonInputWithHeadersAndAllParams:Request", async () => {
}
});

/**
* Sends a GET request that uses URI label bindings
*/
it("RestJsonHttpRequestLabelEscaping:Request", async () => {
const client = new RestJsonProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
});

const command = new HttpRequestWithLabelsCommand({
string: "%:/?#[]@!$&'()*+,;=😹",

short: 1,

integer: 2,

long: 3,

float: 4.1,

double: 5.1,

boolean: true,

timestamp: new Date(1576540098000),
} 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("GET");
expect(r.path).toBe(
"/HttpRequestWithLabels/%25%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%F0%9F%98%B9/1/2/3/4.1/5.1/true/2019-12-16T23%3A48%3A18Z"
);

expect(r.body).toBeFalsy();
}
});

/**
* Serializes different timestamp formats in URI labels
*/
Expand Down