Skip to content
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

fix(codegen): pass through sha256 in non-AWS sigv4 generated client #6415

Merged
merged 1 commit into from
Aug 28, 2024
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
7 changes: 2 additions & 5 deletions codegen/generic-client-test-codegen/model/weather.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ $version: "2.0"
namespace example.weather

use aws.auth#sigv4
use aws.protocols#restJson1

@authDefinition
@trait
structure customAuth {}

@trait
@protocolDefinition
structure fakeProtocol {}

@fakeProtocol
@restJson1
@httpApiKeyAuth(name: "X-Api-Key", in: "header")
@httpBearerAuth
@sigv4(name: "weather")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public Optional<HttpAuthScheme> getHttpAuthScheme() {
*/
signingProperties: {
context,
sha256: (config as any).sha256,
},
};
},"""))
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-ec2/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-json-10/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-json/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-query/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-restjson/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-restxml/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const partitionHash: PartitionHash = {
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"eu-central-1",
Expand Down
23 changes: 23 additions & 0 deletions private/aws-util-test/src/clients/Weather.integ.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Weather } from "@aws-sdk/weather";

import { requireRequestsFrom } from "../requests/test-http-handler";

describe(Weather.name, () => {
it("should be able to make a request without errors", async () => {
const client = new Weather({
credentials: {
accessKeyId: "",
secretAccessKey: "",
},
endpoint: "https://localhost",
});

requireRequestsFrom(client).toMatch({
body: /./,
});

await client.onlySigv4Auth({});

expect.hasAssertions();
});
});
6 changes: 5 additions & 1 deletion private/weather-legacy-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@aws-crypto/sha256-js": "5.2.0",
"@aws-sdk/client-sso-oidc": "*",
"@aws-sdk/client-sts": "*",
"@aws-sdk/core": "*",
"@aws-sdk/credential-provider-node": "*",
"@aws-sdk/middleware-host-header": "*",
"@aws-sdk/middleware-logger": "*",
Expand All @@ -32,6 +33,7 @@
"@aws-sdk/util-user-agent-browser": "*",
"@aws-sdk/util-user-agent-node": "*",
"@smithy/config-resolver": "^3.0.5",
"@smithy/core": "^2.4.0",
"@smithy/fetch-http-handler": "^3.2.4",
"@smithy/hash-node": "^3.0.3",
"@smithy/invalid-dependency": "^3.0.3",
Expand All @@ -53,11 +55,13 @@
"@smithy/util-middleware": "^3.0.3",
"@smithy/util-retry": "^3.0.3",
"@smithy/util-utf8": "^3.0.0",
"tslib": "^2.6.2"
"tslib": "^2.6.2",
"uuid": "^9.0.1"
},
"devDependencies": {
"@tsconfig/node16": "16.1.3",
"@types/node": "^16.18.96",
"@types/uuid": "^9.0.4",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"rimraf": "3.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlyCustomAuthCommand, se_OnlyCustomAuthCommand } from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -63,10 +64,6 @@ export class OnlyCustomAuthCommand extends $Command
.s("Weather", "OnlyCustomAuth", {})
.n("WeatherClient", "OnlyCustomAuthCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyCustomAuthCommand)
.de(de_OnlyCustomAuthCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlyCustomAuthOptionalCommand, se_OnlyCustomAuthOptionalCommand } from "../protocols/Aws_restJson1";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,10 +63,6 @@ export class OnlyCustomAuthOptionalCommand extends $Command
.s("Weather", "OnlyCustomAuthOptional", {})
.n("WeatherClient", "OnlyCustomAuthOptionalCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyCustomAuthOptionalCommand)
.de(de_OnlyCustomAuthOptionalCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { getHttpApiKeyAuthPlugin } from "../middleware/HttpApiKeyAuth";
import {
de_OnlyHttpApiKeyAndBearerAuthCommand,
se_OnlyHttpApiKeyAndBearerAuthCommand,
} from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -71,10 +75,6 @@ export class OnlyHttpApiKeyAndBearerAuthCommand extends $Command
.s("Weather", "OnlyHttpApiKeyAndBearerAuth", {})
.n("WeatherClient", "OnlyHttpApiKeyAndBearerAuthCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpApiKeyAndBearerAuthCommand)
.de(de_OnlyHttpApiKeyAndBearerAuthCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { getHttpApiKeyAuthPlugin } from "../middleware/HttpApiKeyAuth";
import {
de_OnlyHttpApiKeyAndBearerAuthReversedCommand,
se_OnlyHttpApiKeyAndBearerAuthReversedCommand,
} from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -71,10 +75,6 @@ export class OnlyHttpApiKeyAndBearerAuthReversedCommand extends $Command
.s("Weather", "OnlyHttpApiKeyAndBearerAuthReversed", {})
.n("WeatherClient", "OnlyHttpApiKeyAndBearerAuthReversedCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpApiKeyAndBearerAuthReversedCommand)
.de(de_OnlyHttpApiKeyAndBearerAuthReversedCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { getHttpApiKeyAuthPlugin } from "../middleware/HttpApiKeyAuth";
import { de_OnlyHttpApiKeyAuthCommand, se_OnlyHttpApiKeyAuthCommand } from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -71,10 +72,6 @@ export class OnlyHttpApiKeyAuthCommand extends $Command
.s("Weather", "OnlyHttpApiKeyAuth", {})
.n("WeatherClient", "OnlyHttpApiKeyAuthCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpApiKeyAuthCommand)
.de(de_OnlyHttpApiKeyAuthCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlyHttpApiKeyAuthOptionalCommand, se_OnlyHttpApiKeyAuthOptionalCommand } from "../protocols/Aws_restJson1";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,10 +63,6 @@ export class OnlyHttpApiKeyAuthOptionalCommand extends $Command
.s("Weather", "OnlyHttpApiKeyAuthOptional", {})
.n("WeatherClient", "OnlyHttpApiKeyAuthOptionalCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpApiKeyAuthOptionalCommand)
.de(de_OnlyHttpApiKeyAuthOptionalCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlyHttpBearerAuthCommand, se_OnlyHttpBearerAuthCommand } from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -63,10 +64,6 @@ export class OnlyHttpBearerAuthCommand extends $Command
.s("Weather", "OnlyHttpBearerAuth", {})
.n("WeatherClient", "OnlyHttpBearerAuthCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpBearerAuthCommand)
.de(de_OnlyHttpBearerAuthCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlyHttpBearerAuthOptionalCommand, se_OnlyHttpBearerAuthOptionalCommand } from "../protocols/Aws_restJson1";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,10 +63,6 @@ export class OnlyHttpBearerAuthOptionalCommand extends $Command
.s("Weather", "OnlyHttpBearerAuthOptional", {})
.n("WeatherClient", "OnlyHttpBearerAuthOptionalCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlyHttpBearerAuthOptionalCommand)
.de(de_OnlyHttpBearerAuthOptionalCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlySigv4AuthCommand, se_OnlySigv4AuthCommand } from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -63,10 +64,6 @@ export class OnlySigv4AuthCommand extends $Command
.s("Weather", "OnlySigv4Auth", {})
.n("WeatherClient", "OnlySigv4AuthCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlySigv4AuthCommand)
.de(de_OnlySigv4AuthCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { de_OnlySigv4AuthOptionalCommand, se_OnlySigv4AuthOptionalCommand } from "../protocols/Aws_restJson1";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,10 +63,6 @@ export class OnlySigv4AuthOptionalCommand extends $Command
.s("Weather", "OnlySigv4AuthOptional", {})
.n("WeatherClient", "OnlySigv4AuthOptionalCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_OnlySigv4AuthOptionalCommand)
.de(de_OnlySigv4AuthOptionalCommand)
.build() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// smithy-typescript generated code
import { ServiceInputTypes, ServiceOutputTypes, WeatherClientResolvedConfig } from "../WeatherClient";
import { SameAsServiceOutput } from "../models/models_0";
import { de_SameAsServiceCommand, se_SameAsServiceCommand } from "../protocols/Aws_restJson1";
import { getSigV4AuthPlugin } from "@aws-sdk/middleware-signing";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
Expand Down Expand Up @@ -66,10 +67,6 @@ export class SameAsServiceCommand extends $Command
.s("Weather", "SameAsService", {})
.n("WeatherClient", "SameAsServiceCommand")
.f(void 0, void 0)
.ser(() => {
throw new Error("No supported protocol was found");
})
.de(() => {
throw new Error("No supported protocol was found");
})
.ser(se_SameAsServiceCommand)
.de(de_SameAsServiceCommand)
.build() {}
Loading
Loading