diff --git a/clients/client-lex-runtime-service/LexRuntimeService.spec.ts b/clients/client-lex-runtime-service/LexRuntimeService.spec.ts new file mode 100644 index 0000000000000..3ddfbb071a1a2 --- /dev/null +++ b/clients/client-lex-runtime-service/LexRuntimeService.spec.ts @@ -0,0 +1,34 @@ +/// +import { expect } from "chai"; +import { LexRuntimeService } from "./LexRuntimeService"; +import { SerializeMiddleware } from "@aws-sdk/types"; +import { HttpRequest } from "@aws-sdk/protocol-http"; + +describe("@aws-sdk/client-lex-runtime-service", () => { + describe("PostContent", () => { + it("should contain correct x-amz-content-sha256 header", async () => { + const validator: SerializeMiddleware = next => args => { + // middleware intercept the request and return it early + const request = args.request as HttpRequest; + expect(request.headers).to.have.property( + "x-amz-content-sha256", + "UNSIGNED-PAYLOAD" + ); + return Promise.resolve({ output: {} as any, response: {} as any }); + }; + const client = new LexRuntimeService({}); + client.middlewareStack.add(validator, { + step: "serialize", + name: "endpointValidator", + priority: "low" + }); + return await client.postContent({ + botAlias: "alias", + botName: "bot", + userId: "user", + contentType: "text/plain; charset=utf-8", + inputStream: "hello world!" + }); + }); + }); +}); diff --git a/clients/client-lex-runtime-service/package.json b/clients/client-lex-runtime-service/package.json index b11a98ed33fb2..ac7ebd8ef4f90 100644 --- a/clients/client-lex-runtime-service/package.json +++ b/clients/client-lex-runtime-service/package.json @@ -12,7 +12,8 @@ "remove-documentation": "rimraf ./docs", "remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js", "remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map", - "test": "exit 0", + "test:unit": "mocha **/cjs/**/*.spec.js", + "test": "yarn test:unit", "build:es": "tsc -p tsconfig.es.json", "build": "yarn pretest && yarn build:es" }, @@ -60,8 +61,9 @@ "tslib": "^1.8.0" }, "devDependencies": { + "@types/chai": "^4.2.11", + "@types/mocha": "^7.0.2", "@types/node": "^12.7.5", - "jest": "^25.1.0", "rimraf": "^3.0.0", "tslib": "^1.8.0", "typedoc": "^0.15.0", diff --git a/clients/client-lex-runtime-service/protocols/Aws_restJson1.ts b/clients/client-lex-runtime-service/protocols/Aws_restJson1.ts index ab193c1b6fd83..7815b62ff032c 100644 --- a/clients/client-lex-runtime-service/protocols/Aws_restJson1.ts +++ b/clients/client-lex-runtime-service/protocols/Aws_restJson1.ts @@ -179,7 +179,7 @@ export const serializeAws_restJson1PostContentCommand = async ( ): Promise<__HttpRequest> => { const headers: any = { "Content-Type": "application/octet-stream", - "x-amz-content-sha256": "UNSIGNED_PAYLOAD", + "x-amz-content-sha256": "UNSIGNED-PAYLOAD", ...(isSerializableHeaderValue(input.accept) && { Accept: input.accept! }), ...(isSerializableHeaderValue(input.contentType) && { "Content-Type": input.contentType! diff --git a/clients/client-lex-runtime-service/tsconfig.json b/clients/client-lex-runtime-service/tsconfig.json index ca2fadc08187b..3b53843739832 100644 --- a/clients/client-lex-runtime-service/tsconfig.json +++ b/clients/client-lex-runtime-service/tsconfig.json @@ -12,7 +12,8 @@ "incremental": true, "resolveJsonModule": true, "declarationDir": "./types", - "outDir": "dist/cjs" + "outDir": "dist/cjs", + "types": ["mocha", "node"] }, "typedocOptions": { "exclude": "**/node_modules/**", diff --git a/clients/client-mediastore-data/MidiaStoreData.spec.ts b/clients/client-mediastore-data/MidiaStoreData.spec.ts new file mode 100644 index 0000000000000..c815b9111a9af --- /dev/null +++ b/clients/client-mediastore-data/MidiaStoreData.spec.ts @@ -0,0 +1,31 @@ +/// +import { expect } from "chai"; +import { MediaStoreData } from "./MediaStoreData"; +import { SerializeMiddleware } from "@aws-sdk/types"; +import { HttpRequest } from "@aws-sdk/protocol-http"; + +describe("@aws-sdk/client-mediastore-data", () => { + describe("PutObject", () => { + it("should contain correct x-amz-content-sha256 header", async () => { + const validator: SerializeMiddleware = next => args => { + // middleware intercept the request and return it early + const request = args.request as HttpRequest; + expect(request.headers).to.have.property( + "x-amz-content-sha256", + "UNSIGNED-PAYLOAD" + ); + return Promise.resolve({ output: {} as any, response: {} as any }); + }; + const client = new MediaStoreData({}); + client.middlewareStack.add(validator, { + step: "serialize", + name: "endpointValidator", + priority: "low" + }); + return await client.putObject({ + Path: "foo.avi", + Body: "binary body" + }); + }); + }); +}); diff --git a/clients/client-mediastore-data/package.json b/clients/client-mediastore-data/package.json index bdebf576646a8..704f5e98dc3b6 100644 --- a/clients/client-mediastore-data/package.json +++ b/clients/client-mediastore-data/package.json @@ -12,7 +12,8 @@ "remove-documentation": "rimraf ./docs", "remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js", "remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map", - "test": "exit 0", + "test:unit": "mocha **/cjs/**/*.spec.js", + "test": "yarn test:unit", "build:es": "tsc -p tsconfig.es.json", "build": "yarn pretest && yarn build:es" }, @@ -60,8 +61,9 @@ "tslib": "^1.8.0" }, "devDependencies": { + "@types/chai": "^4.2.11", + "@types/mocha": "^7.0.2", "@types/node": "^12.7.5", - "jest": "^25.1.0", "rimraf": "^3.0.0", "tslib": "^1.8.0", "typedoc": "^0.15.0", diff --git a/clients/client-mediastore-data/protocols/Aws_restJson1.ts b/clients/client-mediastore-data/protocols/Aws_restJson1.ts index 5ab49d1de5ddb..9633771cf9edb 100644 --- a/clients/client-mediastore-data/protocols/Aws_restJson1.ts +++ b/clients/client-mediastore-data/protocols/Aws_restJson1.ts @@ -184,7 +184,7 @@ export const serializeAws_restJson1PutObjectCommand = async ( ): Promise<__HttpRequest> => { const headers: any = { "Content-Type": "application/octet-stream", - "x-amz-content-sha256": "UNSIGNED_PAYLOAD", + "x-amz-content-sha256": "UNSIGNED-PAYLOAD", ...(isSerializableHeaderValue(input.CacheControl) && { "Cache-Control": input.CacheControl! }), diff --git a/clients/client-mediastore-data/tsconfig.json b/clients/client-mediastore-data/tsconfig.json index ca2fadc08187b..e4c7e496e4440 100644 --- a/clients/client-mediastore-data/tsconfig.json +++ b/clients/client-mediastore-data/tsconfig.json @@ -12,7 +12,8 @@ "incremental": true, "resolveJsonModule": true, "declarationDir": "./types", - "outDir": "dist/cjs" + "outDir": "dist/cjs", + "types": ["mocha"] }, "typedocOptions": { "exclude": "**/node_modules/**", 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 2989e2ee2778b..0cd517fa1a6c4 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 @@ -45,7 +45,7 @@ final class AwsProtocolUtils { private AwsProtocolUtils() {} /** - * Writes an {@code 'x-amz-content-sha256' = 'UNSIGNED_PAYLOAD'} header for an + * Writes an {@code 'x-amz-content-sha256' = 'UNSIGNED-PAYLOAD'} header for an * {@code @aws.api#unsignedPayload} trait that specifies the {@code "aws.v4"} auth scheme. * * @see @aws.api#unsignedPayload trait @@ -58,7 +58,7 @@ static void generateUnsignedPayloadSigV4Header(GenerationContext context, Operat operation.getTrait(UnsignedPayloadTrait.class) .ifPresent(trait -> { - writer.write("'x-amz-content-sha256': 'UNSIGNED_PAYLOAD',"); + writer.write("'x-amz-content-sha256': 'UNSIGNED-PAYLOAD',"); }); }