Skip to content

Commit cd8dfab

Browse files
committed
test: create e2e global hook
1 parent 05d9ef8 commit cd8dfab

File tree

19 files changed

+62
-36
lines changed

19 files changed

+62
-36
lines changed

clients/client-cognito-identity/test/e2e/CognitoIdentity.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { beforeAll, describe, expect, test as it } from "vitest";
23

34
import { getIntegTestResources } from "../../../../tests/e2e/get-integ-test-resources";
@@ -9,6 +10,7 @@ describe("@aws-sdk/client-cognito-identity", () => {
910
let IdentityPoolId: string;
1011

1112
beforeAll(async () => {
13+
await setTestCredentials();
1214
const integTestResourcesEnv = await getIntegTestResources();
1315
Object.assign(process.env, integTestResourcesEnv);
1416

clients/client-kinesis/test/Kinesis.e2e.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { describe, expect, test as it } from "vitest";
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
2+
import { beforeAll, describe, expect, test as it } from "vitest";
23

34
import { KinesisClient, ListStreamsCommand } from "../src/index";
45

56
describe("@aws-sdk/client-kinesis", () => {
7+
beforeAll(async () => {
8+
await setTestCredentials();
9+
});
10+
611
const client = new KinesisClient({
712
region: "us-west-2",
8-
credentials: {
9-
accessKeyId: "CLIENT_TEST",
10-
secretAccessKey: "CLIENT_TEST",
11-
},
1213
});
1314
const ONE_SECOND = 1 * 1000;
1415

clients/client-s3/test/e2e/S3.browser.e2e.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/**
2-
* This is the integration test that make sure the client can make request cross-platform-ly
3-
* in NodeJS and browsers.
4-
*/
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
52
import type { S3, SelectObjectContentEventStream } from "@aws-sdk/client-s3";
63
import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
74
import { FetchHttpHandler } from "@smithy/fetch-http-handler";
@@ -20,6 +17,7 @@ describe("@aws-sdk/client-s3", () => {
2017
let Key = `${Date.now()}`;
2118

2219
beforeAll(async () => {
20+
await setTestCredentials();
2321
const integTestResourcesEnv = await getIntegTestResources();
2422
Object.assign(process.env, integTestResourcesEnv);
2523

clients/client-s3/test/e2e/S3.e2e.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@aws-sdk/signature-v4-crt";
22

3+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
34
import { S3, SelectObjectContentEventStream } from "@aws-sdk/client-s3";
4-
import { AwsCredentialIdentity } from "@aws-sdk/types";
55
import { afterAll, afterEach, beforeAll, describe, expect, test as it } from "vitest";
66

77
import { getIntegTestResources } from "../../../../tests/e2e/get-integ-test-resources";
@@ -13,23 +13,21 @@ describe("@aws-sdk/client-s3", () => {
1313
let client: S3;
1414
let Bucket: string;
1515
let region: string;
16-
let credentials: AwsCredentialIdentity;
1716
let mrapArn: string;
1817

1918
beforeAll(async () => {
19+
await setTestCredentials();
2020
const integTestResourcesEnv = await getIntegTestResources();
2121
Object.assign(process.env, integTestResourcesEnv);
2222

2323
region = process?.env?.AWS_SMOKE_TEST_REGION as string;
24-
credentials = (globalThis as any).credentials || undefined;
2524
Bucket = process?.env?.AWS_SMOKE_TEST_BUCKET as string;
2625
mrapArn = (globalThis as any)?.window?.__env__?.AWS_SMOKE_TEST_MRAP_ARN || process?.env?.AWS_SMOKE_TEST_MRAP_ARN;
2726

2827
Key = ``;
2928

3029
client = new S3({
3130
region,
32-
credentials,
3331
});
3432
});
3533

clients/client-transcribe-streaming/test/index.e2e.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { createReadStream } from "fs";
23
import { join } from "path";
3-
import { afterAll, describe, expect, test as it } from "vitest";
4+
import { afterAll, beforeAll, describe, expect, test as it } from "vitest";
45

56
import { TranscribeStreaming } from "../src/index";
67
const audio = createReadStream(join(__dirname, "numbers.wav"));
@@ -13,6 +14,10 @@ describe("TranscribeStream client", () => {
1314
secretAccessKey: "CLIENT_TEST",
1415
},
1516
});
17+
18+
beforeAll(async () => {
19+
await setTestCredentials();
20+
});
1621
afterAll(() => {
1722
client.destroy();
1823
});

lib/lib-dynamodb/src/test/lib-dynamodb.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import {
23
BillingMode,
34
CreateTableCommandOutput,
@@ -196,6 +197,7 @@ describe(
196197
const passError = (e: any) => e;
197198

198199
beforeAll(async () => {
200+
await setTestCredentials();
199201
log.describe = await dynamodb
200202
.describeTable({
201203
TableName,

lib/lib-storage/src/lib-storage.e2e.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { S3 } from "@aws-sdk/client-s3";
23
import { Upload } from "@aws-sdk/lib-storage";
34
import type { AwsCredentialIdentity } from "@smithy/types";
@@ -14,14 +15,13 @@ describe("@aws-sdk/lib-storage", () => {
1415
let dataString: string;
1516
let Bucket: string;
1617
let region: string;
17-
let credentials: AwsCredentialIdentity;
1818

1919
beforeAll(async () => {
20+
await setTestCredentials();
2021
const integTestResourcesEnv = await getIntegTestResources();
2122
Object.assign(process.env, integTestResourcesEnv);
2223

2324
region = process?.env?.AWS_SMOKE_TEST_REGION as string;
24-
credentials = (globalThis as any).credentials || undefined;
2525
Bucket = process?.env?.AWS_SMOKE_TEST_BUCKET as string;
2626

2727
Key = ``;
@@ -30,7 +30,6 @@ describe("@aws-sdk/lib-storage", () => {
3030

3131
client = new S3({
3232
region,
33-
credentials,
3433
});
3534
});
3635

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"local-publish": "node ./scripts/verdaccio-publish/index.js",
3535
"test:all": "yarn build:all && jest --passWithNoTests && lerna run test --scope '@aws-sdk/{fetch-http-handler,hash-blob-browser}' && yarn test:versions && yarn test:integration",
3636
"test:ci": "lerna run test --since origin/main",
37-
"test:e2e": "node ./scripts/turbo test:e2e && node ./tests/canary/canary",
37+
"test:e2e": "export AWS_PROFILE=sdk-integ-test && node -e \"console.log(process.env)\" && node ./scripts/turbo test:e2e && node ./tests/canary/canary",
3838
"test:e2e:legacy": "cucumber-js --fail-fast",
3939
"test:e2e:legacy:preview": "./tests/e2e-legacy/preview.mjs",
4040
"test:e2e:legacy:since:release": "./tests/e2e-legacy/since-release.mjs",

packages/ec2-metadata-service/src/MetadataService.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { fromInstanceMetadata } from "@aws-sdk/credential-providers";
23
import { beforeAll, describe, expect, test as it, vi } from "vitest";
34

@@ -9,6 +10,7 @@ describe("MetadataService E2E Tests", () => {
910
let metadataServiceAvailable: any;
1011

1112
beforeAll(async () => {
13+
await setTestCredentials();
1214
try {
1315
await provider();
1416
metadataServiceAvailable = true;

packages/middleware-sdk-s3/src/region-redirect-middleware.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { S3 } from "@aws-sdk/client-s3";
23
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
34
import { afterAll, beforeAll, describe, expect, test as it } from "vitest";
@@ -22,6 +23,7 @@ describe("S3 Global Client Test", () => {
2223
const randId = alphabet[(Math.random() * alphabet.length) | 0] + alphabet[(Math.random() * alphabet.length) | 0];
2324

2425
beforeAll(async () => {
26+
await setTestCredentials();
2527
callerID = await stsClient.getCallerIdentity({});
2628
bucketNames = regionConfigs.map((config) => `${callerID.Account}-${randId}-redirect-${config.region}`);
2729
await Promise.all(bucketNames.map((bucketName, index) => deleteBucket(s3Clients[index], bucketName)));

packages/middleware-sdk-s3/src/s3-expires-middleware.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { S3 } from "@aws-sdk/client-s3";
23
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
34
import { afterAll, beforeAll, describe, expect, test as it, vi } from "vitest";
@@ -24,6 +25,7 @@ describe("S3 Expires e2e test", () => {
2425
const randId = alphabet[(Math.random() * alphabet.length) | 0] + alphabet[(Math.random() * alphabet.length) | 0];
2526

2627
beforeAll(async () => {
28+
await setTestCredentials();
2729
callerID = await stsClient.getCallerIdentity({});
2830
Bucket = `${callerID.Account}-${randId}-s3-expires`;
2931
await s3.createBucket({

packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { GetObjectCommand, PutObjectCommand, S3, waitUntilBucketExists } from "@aws-sdk/client-s3";
23
import { STS } from "@aws-sdk/client-sts";
34
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
@@ -34,6 +35,7 @@ describe("s3 express CRUD test suite", () => {
3435
let readWriteDeleteRecorder: typeof recorder.calls;
3536

3637
beforeAll(async () => {
38+
await setTestCredentials();
3739
({ s3, controller, bucketName, recorder } = await createClientAndRecorder());
3840

3941
await s3.createBucket({

packages/middleware-sdk-s3/src/throw-200-exceptions.e2e.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
12
import { S3 } from "@aws-sdk/client-s3";
23
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
34
import { afterAll, beforeAll, describe, test as it } from "vitest";
@@ -15,6 +16,7 @@ describe("S3 throw 200 exceptions", () => {
1516
let callerID: GetCallerIdentityCommandOutput;
1617

1718
beforeAll(async () => {
19+
await setTestCredentials();
1820
callerID = await stsClient.getCallerIdentity({});
1921
Bucket = `${callerID.Account}-${randId}-s3-200s-e2e-test-empty-${config.region}-${(Date.now() / 1000) | 0}`;
2022

packages/s3-presigned-post/src/createPresignedPost.e2e.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Run using AWS_SMOKE_TEST_REGION=[Region] AWS_SMOKE_TEST_BUCKET=[Bucket] yarn test:e2e
2-
// These params are established in /tests/e2e.
1+
import { setTestCredentials } from "@aws-sdk/aws-util-test";
32
import { NoSuchKey, S3 } from "@aws-sdk/client-s3";
43
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test as it } from "vitest";
54

@@ -16,6 +15,7 @@ describe(createPresignedPost.name, () => {
1615
let region: string;
1716

1817
beforeAll(async () => {
18+
await setTestCredentials();
1919
const integTestResourcesEnv = await getIntegTestResources();
2020
Object.assign(process.env, integTestResourcesEnv);
2121

private/aws-util-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"dependencies": {
2020
"@aws-sdk/aws-protocoltests-json": "*",
2121
"@smithy/protocol-http": "^4.1.4",
22+
"@smithy/shared-ini-file-loader": "^3.1.8",
2223
"@smithy/types": "^3.5.0",
2324
"tslib": "^2.6.2"
2425
},

private/aws-util-test/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./requests/test-http-handler";
2+
export * from "./set-test-credentials";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { loadSharedConfigFiles } from "@smithy/shared-ini-file-loader";
2+
3+
export const setTestCredentials = async () => {
4+
const ini = await loadSharedConfigFiles();
5+
const profileData = ini.configFile["sdk-integ-test"] ?? ini.credentialsFile["sdk-integ-test"];
6+
if (profileData) {
7+
// console.log("Setting AWS_PROFILE=sdk-integ-test");
8+
// process.env.AWS_PROFILE = "sdk-integ-test";
9+
} else {
10+
// console.log("AWS_PROFILE is", process.env.AWS_PROFILE);
11+
}
12+
};

scripts/turbo/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
// Build script to handle Turborepo build execution
22
const { spawnProcess } = require("../utils/spawn-process");
33
const path = require("path");
4+
const { loadSharedConfigFiles } = require("@smithy/shared-ini-file-loader");
45

56
const runTurbo = async (task, args, { apiSecret, apiEndpoint, apiSignatureKey } = {}) => {
67
const command = ["turbo", "run", task, "--concurrency=100%", "--output-logs=hash-only"];
78
command.push(...args);
89
const turboRoot = path.join(__dirname, "..", "..");
10+
11+
const ini = await loadSharedConfigFiles();
12+
const profileData = ini.configFile["sdk-integ-test"];
13+
if (profileData) {
14+
console.log("Setting AWS_PROFILE=sdk-integ-test");
15+
process.env.AWS_PROFILE = "sdk-integ-test";
16+
}
17+
918
try {
1019
return await spawnProcess("yarn", command, {
1120
stdio: "inherit",

tests/e2e/get-integ-test-resources.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,15 @@ const { S3ControlClient, ListMultiRegionAccessPointsCommand } = require("@aws-sd
66
const { ensureTestStack } = require("./ensure-test-stack");
77
const { deleteStaleChangesets } = require("./delete-stale-changesets");
88
const { loadSharedConfigFiles } = require("@smithy/shared-ini-file-loader");
9-
const { createCredentialChain, fromIni, fromHttp } = require("@aws-sdk/credential-providers");
109

1110
exports.getIntegTestResources = async () => {
12-
const ini = await loadSharedConfigFiles();
13-
const profileData = ini.configFile["sdk-integ-test"] ?? ini.credentialsFile["sdk-integ-test"];
14-
if (profileData) {
15-
console.log("Setting AWS_PROFILE=sdk-integ-test");
16-
process.env.AWS_PROFILE = "sdk-integ-test";
17-
if (profileData.role_arn) {
18-
console.log(
19-
`Setting AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`
20-
);
21-
process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = `/role-arn/${profileData.role_arn}`;
22-
}
23-
} else {
24-
console.log("AWS_PROFILE is", process.env.AWS_PROFILE);
25-
}
26-
2711
const region = "us-west-2";
12+
13+
console.log({ files: await loadSharedConfigFiles(), ENV: process.env });
14+
2815
const cloudformation = new CloudFormationClient({
2916
region,
17+
logger: console,
3018
});
3119
const stackName = "SdkReleaseV3IntegTestResourcesStack";
3220

0 commit comments

Comments
 (0)