From ed92f5670165c9d89bbaff4515433735c93b0409 Mon Sep 17 00:00:00 2001 From: Steven Yuan Date: Tue, 5 Sep 2023 12:06:28 -0700 Subject: [PATCH] feat(experimentalIdentityAndAuth): copy smithy-typescript generic auth tests --- .../build.gradle.kts | 1 + .../model/weather.smithy | 84 +++++++++++++++++++ .../smithy-build.json | 49 +++++++++++ 3 files changed, 134 insertions(+) create mode 100644 codegen/generic-client-test-codegen/model/weather.smithy diff --git a/codegen/generic-client-test-codegen/build.gradle.kts b/codegen/generic-client-test-codegen/build.gradle.kts index f2c9da796ace9..da69f9602b98a 100644 --- a/codegen/generic-client-test-codegen/build.gradle.kts +++ b/codegen/generic-client-test-codegen/build.gradle.kts @@ -36,6 +36,7 @@ plugins { dependencies { implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion") + implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation(project(":smithy-aws-typescript-codegen")) } diff --git a/codegen/generic-client-test-codegen/model/weather.smithy b/codegen/generic-client-test-codegen/model/weather.smithy new file mode 100644 index 0000000000000..da2e2a7759ea5 --- /dev/null +++ b/codegen/generic-client-test-codegen/model/weather.smithy @@ -0,0 +1,84 @@ +$version: "2.0" + +namespace example.weather + +use aws.auth#sigv4 + +@authDefinition +@trait +structure customAuth {} + +@trait +@protocolDefinition +structure fakeProtocol {} + +@fakeProtocol +@httpApiKeyAuth(name: "X-Api-Key", in: "header") +@httpBearerAuth +@sigv4(name: "weather") +@customAuth +@auth([sigv4]) +service Weather { + version: "2006-03-01" + operations: [ + // experimentalIdentityAndAuth + OnlyHttpApiKeyAuth + OnlyHttpApiKeyAuthOptional + OnlyHttpBearerAuth + OnlyHttpBearerAuthOptional + OnlyHttpApiKeyAndBearerAuth + OnlyHttpApiKeyAndBearerAuthReversed + OnlySigv4Auth + OnlySigv4AuthOptional + OnlyCustomAuth + OnlyCustomAuthOptional + SameAsService + ] +} + +@http(method: "GET", uri: "/OnlyHttpApiKeyAuth") +@auth([httpApiKeyAuth]) +operation OnlyHttpApiKeyAuth {} + +@http(method: "GET", uri: "/OnlyHttpBearerAuth") +@auth([httpBearerAuth]) +operation OnlyHttpBearerAuth {} + +@http(method: "GET", uri: "/OnlySigv4Auth") +@auth([sigv4]) +operation OnlySigv4Auth {} + +@http(method: "GET", uri: "/OnlyHttpApiKeyAndBearerAuth") +@auth([httpApiKeyAuth, httpBearerAuth]) +operation OnlyHttpApiKeyAndBearerAuth {} + +@http(method: "GET", uri: "/OnlyHttpApiKeyAndBearerAuthReversed") +@auth([httpBearerAuth, httpApiKeyAuth]) +operation OnlyHttpApiKeyAndBearerAuthReversed {} + +@http(method: "GET", uri: "/OnlyHttpApiKeyAuthOptional") +@auth([httpApiKeyAuth]) +@optionalAuth +operation OnlyHttpApiKeyAuthOptional {} + +@http(method: "GET", uri: "/OnlyHttpBearerAuthOptional") +@auth([httpBearerAuth]) +@optionalAuth +operation OnlyHttpBearerAuthOptional {} + +@http(method: "GET", uri: "/OnlySigv4AuthOptional") +@auth([sigv4]) +@optionalAuth +operation OnlySigv4AuthOptional {} + +@http(method: "GET", uri: "/OnlyCustomAuth") +@auth([customAuth]) +operation OnlyCustomAuth {} + +@http(method: "GET", uri: "/OnlyCustomAuthOptional") +@auth([customAuth]) +@optionalAuth +operation OnlyCustomAuthOptional {} + +@http(method: "GET", uri: "/SameAsService") +operation SameAsService {} diff --git a/codegen/generic-client-test-codegen/smithy-build.json b/codegen/generic-client-test-codegen/smithy-build.json index 33ca19c221a99..d3059f9e3978c 100644 --- a/codegen/generic-client-test-codegen/smithy-build.json +++ b/codegen/generic-client-test-codegen/smithy-build.json @@ -2,6 +2,55 @@ "version": "1.0", "imports": ["model/echo.smithy"], "projections": { + "client-experimental-identity-and-auth": { + "transforms": [ + { + "name": "includeServices", + "args": { + "services": ["example.weather#Weather"] + } + } + ], + "plugins": { + "typescript-codegen": { + "package": "@aws-sdk/weather", + "packageVersion": "0.0.1", + "packageJson": { + "author": { + "name": "AWS SDK for JavaScript Team", + "url": "https://aws.amazon.com/javascript/" + }, + "license": "Apache-2.0" + }, + "private": true, + "experimentalIdentityAndAuth": true + } + } + }, + "control-experimental-identity-and-auth": { + "transforms": [ + { + "name": "includeServices", + "args": { + "services": ["example.weather#Weather"] + } + } + ], + "plugins": { + "typescript-codegen": { + "package": "@aws-sdk/weather", + "packageVersion": "0.0.1", + "packageJson": { + "author": { + "name": "AWS SDK for JavaScript Team", + "url": "https://aws.amazon.com/javascript/" + }, + "license": "Apache-2.0" + }, + "private": true + } + } + }, "aws-echo-service": { "transforms": [ {