Skip to content

Commit b53f5bd

Browse files
authored
fix(endpoint): e2e test fixes for endpoints 2.0 all services (#4044)
1 parent f2da618 commit b53f5bd

File tree

12 files changed

+78
-17
lines changed

12 files changed

+78
-17
lines changed

features/extra/hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Given("I run the {string} operation with params:", function (operation, params,
6464
});
6565

6666
Then("the request should be successful", function (callback) {
67-
this.assert.ok(!this.error, "Response was not successful");
67+
this.assert.ok(!this.error, "Response was not successful: " + this.error);
6868
callback();
6969
});
7070

features/rds/rds.feature

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Feature: Amazon Relational Database Service
55
I want to use Amazon Relational Database Service
66

77
Scenario: Describe DB security group
8+
Given I create a RDS security group with prefix name "aws-sdk-js-rds-e2e"
89
Given I run the "describeDBSecurityGroups" operation
910
Then the request should be successful
1011
And the value at "DBSecurityGroups" should be a list
11-
And the value at "DBSecurityGroups" should contain "DBSecurityGroupDescription" with "default"
12+
And the value at "DBSecurityGroups" should contain "DBSecurityGroupDescription" with "Description"
1213

1314
Scenario: Error handling
1415
Given I create a RDS security group with prefix name ""

features/rds/step_definitions/rds.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
const jmespath = require("jmespath");
2-
const { Before, Given, Then } = require("@cucumber/cucumber");
2+
const { After, Before, Given, Then } = require("@cucumber/cucumber");
3+
4+
const dbsgNames = [];
35

46
Before({ tags: "@rds" }, function (scenario, callback) {
57
const { RDS } = require("../../../clients/client-rds");
68
this.service = new RDS({});
79
callback();
810
});
911

12+
After({ tags: "@rds" }, async function () {
13+
while (dbsgNames.length) {
14+
const name = dbsgNames.pop();
15+
if (name) {
16+
await this.service.deleteDBSecurityGroup({
17+
DBSecurityGroupName: name,
18+
});
19+
}
20+
}
21+
});
22+
1023
Given("I create a RDS security group with prefix name {string}", function (prefix, callback) {
1124
this.dbGroupName = this.uniqueName(prefix);
25+
dbsgNames.push(this.dbGroupName);
1226
const params = {
1327
DBSecurityGroupDescription: "Description",
1428
DBSecurityGroupName: this.dbGroupName,
@@ -24,7 +38,10 @@ Then("the value at {string} should contain {string} with {string}", function (pa
2438
containDefault = true;
2539
}
2640
});
27-
this.assert.ok(containDefault === true, `No ${path} has member key ${key} of the value ${value}`);
41+
this.assert.ok(
42+
containDefault === true,
43+
`No ${path} has member key ${key} of the value ${value}: ${JSON.stringify(this.data, null, 2)}`
44+
);
2845
callback();
2946
});
3047

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@commitlint/cli": "17.0.2",
5454
"@commitlint/config-conventional": "17.0.2",
5555
"@cucumber/cucumber": "8.5.3",
56+
"@cucumber/pretty-formatter": "^1.0.0",
5657
"@mixer/parallel-prettier": "2.0.3",
5758
"@tsconfig/recommended": "1.0.1",
5859
"@types/chai-as-promised": "^7.1.2",

packages/middleware-endpoint/src/endpointMiddleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const endpointMiddleware = <T extends EndpointParameters>({
4646

4747
const authScheme: AuthScheme = context.authSchemes?.[0];
4848
if (authScheme) {
49-
context["signing_region"] = authScheme.signingScope;
49+
context["signing_region"] = authScheme.signingRegion;
5050
context["signing_service"] = authScheme.signingName;
5151
}
5252

packages/middleware-sdk-s3-control/src/process-arnables-plugin/parse-outpost-arnables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const parseOutpostArnablesMiddleaware =
4848
useDualstackEndpoint,
4949
}))!);
5050
} else {
51-
signingRegion = context.endpointV2?.properties?.authSchemes?.[0]?.signingScope || baseRegion;
51+
signingRegion = context.endpointV2?.properties?.authSchemes?.[0]?.signingRegion || baseRegion;
5252
clientPartition = partition(signingRegion).name;
5353
}
5454

packages/middleware-signing/src/configuration.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { resolveAwsAuthConfig, resolveSigV4AuthConfig } from "./configurations";
55
describe("AuthConfig", () => {
66
const authScheme = {
77
name: "sigv4",
8-
signingScope: "UNIT_TEST_REGION",
8+
signingRegion: "UNIT_TEST_REGION",
99
signingName: "UNIT_TEST_SERVICE_NAME",
1010
properties: {},
1111
};

packages/middleware-signing/src/configurations.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ interface PreviouslyResolved {
8282
region: string | Provider<string>;
8383
regionInfoProvider?: RegionInfoProvider;
8484
signingName?: string;
85+
defaultSigningName?: string;
8586
serviceId: string;
8687
sha256: HashConstructor;
8788
useFipsEndpoint: Provider<boolean>;
@@ -170,10 +171,18 @@ export const resolveAwsAuthConfig = <T>(
170171
// Handle endpoints v2 that resolved per-command
171172
// TODO: need total refactor for reference auth architecture.
172173
signer = async (authScheme?: AuthScheme) => {
173-
if (!authScheme) {
174-
throw new Error("Unexpected empty auth scheme config");
175-
}
176-
const signingRegion = authScheme.signingScope;
174+
authScheme = Object.assign(
175+
{},
176+
{
177+
name: "v4",
178+
signingName: input.signingName || input.defaultSigningName!,
179+
signingRegion: await normalizeProvider(input.region)(),
180+
properties: {},
181+
},
182+
authScheme
183+
);
184+
185+
const signingRegion = authScheme.signingRegion;
177186
const signingService = authScheme.signingName;
178187
// update client's singing region and signing service config if they are resolved.
179188
// signing region resolving order: user supplied signingRegion -> endpoints.json inferred region -> client region
@@ -190,6 +199,7 @@ export const resolveAwsAuthConfig = <T>(
190199
sha256,
191200
uriEscapePath: signingEscapePath,
192201
};
202+
193203
const SignerCtor = input.signerConstructor || SignatureV4;
194204
return new SignerCtor(params);
195205
};

packages/middleware-signing/src/middleware.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
22
import {
33
AuthScheme,
4-
EndpointV2,
54
FinalizeHandler,
65
FinalizeHandlerArguments,
76
FinalizeHandlerOutput,
@@ -24,7 +23,7 @@ export const awsAuthMiddleware =
2423
if (!HttpRequest.isInstance(args.request)) return next(args);
2524

2625
// TODO(identityandauth): call authScheme resolver
27-
const authScheme: AuthScheme | undefined = (context.endpointV2)?.properties?.authSchemes?.[0];
26+
const authScheme: AuthScheme | undefined = context.endpointV2?.properties?.authSchemes?.[0];
2827

2928
const signer = await options.signer(authScheme);
3029

packages/s3-request-presigner/src/getSignedUrl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const getSignedUrl = async <
2727
s3Presigner = new S3RequestPresigner({
2828
...client.config,
2929
signingName: authScheme?.signingName,
30-
region: async () => authScheme?.signingScope,
30+
region: async () => authScheme?.signingRegion,
3131
});
3232
} else {
3333
s3Presigner = new S3RequestPresigner(client.config);

packages/types/src/auth.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
*/
44
export interface AuthScheme {
55
/**
6-
* @example "v4" for SigV4
6+
* @example "sigv4a" or "sigv4"
77
*/
8-
name: string;
8+
name: "sigv4" | "sigv4a" | string;
99
/**
1010
* @example "s3"
1111
*/
1212
signingName: string;
1313
/**
1414
* @example "us-east-1"
1515
*/
16-
signingScope: string;
16+
signingRegion: string;
17+
/**
18+
* TODO usage?
19+
*/
20+
signingRegionSet?: string[];
21+
/**
22+
* @deprecated this field was renamed to signingRegion.
23+
*/
24+
signingScope?: never;
1725
properties: Record<string, unknown>;
1826
}

yarn.lock

+25
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"@aws-sdk/hash-node" "*"
9898
"@aws-sdk/invalid-dependency" "*"
9999
"@aws-sdk/middleware-content-length" "*"
100+
"@aws-sdk/middleware-endpoint" "*"
100101
"@aws-sdk/middleware-host-header" "*"
101102
"@aws-sdk/middleware-logger" "*"
102103
"@aws-sdk/middleware-recursion-detection" "*"
@@ -937,6 +938,16 @@
937938
reflect-metadata "0.1.13"
938939
uuid "8.3.2"
939940

941+
"@cucumber/pretty-formatter@^1.0.0":
942+
version "1.0.0"
943+
resolved "https://registry.yarnpkg.com/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz#911014c8fb7472a4c54d00e60e819a7200fd9da3"
944+
integrity sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==
945+
dependencies:
946+
ansi-styles "^5.0.0"
947+
cli-table3 "^0.6.0"
948+
figures "^3.2.0"
949+
ts-dedent "^2.0.0"
950+
940951
"@cucumber/[email protected]":
941952
version "4.1.0"
942953
resolved "https://registry.yarnpkg.com/@cucumber/tag-expressions/-/tag-expressions-4.1.0.tgz#9a91b0e0dd2f2ba703e3038c52b49b9ac06c2c6f"
@@ -3947,6 +3958,15 @@ [email protected]:
39473958
optionalDependencies:
39483959
"@colors/colors" "1.5.0"
39493960

3961+
cli-table3@^0.6.0:
3962+
version "0.6.3"
3963+
resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2"
3964+
integrity sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==
3965+
dependencies:
3966+
string-width "^4.2.0"
3967+
optionalDependencies:
3968+
"@colors/colors" "1.5.0"
3969+
39503970
cli-truncate@^2.1.0:
39513971
version "2.1.0"
39523972
resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7"
@@ -11149,6 +11169,11 @@ trim-newlines@^3.0.0:
1114911169
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
1115011170
integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
1115111171

11172+
ts-dedent@^2.0.0:
11173+
version "2.2.0"
11174+
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5"
11175+
integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==
11176+
1115211177
1115311178
version "28.0.5"
1115411179
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-28.0.5.tgz#31776f768fba6dfc8c061d488840ed0c8eeac8b9"

0 commit comments

Comments
 (0)