Skip to content

Commit 0eb5b20

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

File tree

18 files changed

+61
-35
lines changed

18 files changed

+61
-35
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

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({

0 commit comments

Comments
 (0)