Skip to content

Commit c7dd74d

Browse files
committed
test(clients): add mock credentials to client instantiations
1 parent f1167be commit c7dd74d

File tree

9 files changed

+100
-20
lines changed

9 files changed

+100
-20
lines changed

clients/client-eventbridge/test/EventBridge.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import { describe, expect, test as it } from "vitest";
66
import { EventBridge } from "../src/EventBridge";
77

88
describe("EventBridge", () => {
9-
const client = new EventBridge({});
9+
const client = new EventBridge({
10+
region: "us-west-2",
11+
credentials: {
12+
accessKeyId: "CLIENT_TEST",
13+
secretAccessKey: "CLIENT_TEST",
14+
},
15+
});
1016
// Middleware intercept request and return it before reaching the HTTP client. It records the request and context
1117
// and return them in the Metadata.
1218
const interceptionMiddleware: FinalizeRequestMiddleware<any, any> = (next, context) => (args) => {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { test as it, describe, expect } from "vitest";
1+
import { describe, expect, test as it } from "vitest";
22

33
import { KinesisClient, ListStreamsCommand } from "../src/index";
44

55
describe("@aws-sdk/client-kinesis", () => {
6-
const client = new KinesisClient({});
6+
const client = new KinesisClient({
7+
region: "us-west-2",
8+
credentials: {
9+
accessKeyId: "CLIENT_TEST",
10+
secretAccessKey: "CLIENT_TEST",
11+
},
12+
});
713
const ONE_SECOND = 1 * 1000;
814

915
// TODO: not working in CI

clients/client-lex-runtime-service/test/LexRuntimeService.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ describe("@aws-sdk/client-lex-runtime-service", () => {
1515
};
1616
const client = new LexRuntimeService({
1717
region: "us-west-2",
18+
credentials: {
19+
accessKeyId: "CLIENT_TEST",
20+
secretAccessKey: "CLIENT_TEST",
21+
},
1822
});
1923
client.middlewareStack.add(validator, {
2024
step: "serialize",

clients/client-mediastore-data/test/MediaStoreData.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ describe("@aws-sdk/client-mediastore-data", () => {
1515
};
1616
const client = new MediaStoreData({
1717
region: "us-west-2",
18+
credentials: {
19+
accessKeyId: "CLIENT_TEST",
20+
secretAccessKey: "CLIENT_TEST",
21+
},
1822
});
1923
client.middlewareStack.add(validator, {
2024
step: "serialize",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("@aws-sdk/client-s3", () => {
3333
credentials: fromNodeProviderChain(),
3434
requestHandler: new FetchHttpHandler(),
3535
})
36-
) as S3;
36+
) as unknown as S3;
3737
});
3838

3939
describe("PutObject", () => {

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

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ describe("endpoint", () => {
1717
expect(request.path).to.equal("/path/bucket/key");
1818
return Promise.resolve({ output: {} as any, response: {} as any });
1919
};
20-
const client = new S3({ endpoint: "http://localhost:8080/path", forcePathStyle: true });
20+
const client = new S3({
21+
endpoint: "http://localhost:8080/path",
22+
forcePathStyle: true,
23+
region: "us-west-2",
24+
credentials: {
25+
accessKeyId: "CLIENT_TEST",
26+
secretAccessKey: "CLIENT_TEST",
27+
},
28+
});
2129

2230
client.middlewareStack.add(endpointValidator, {
2331
step: "serialize",
@@ -48,7 +56,13 @@ describe("Endpoints from ARN", () => {
4856

4957
describe("Accesspoint ARN", async () => {
5058
it("should succeed with access point ARN", async () => {
51-
const client = new S3({ region: "us-west-2" });
59+
const client = new S3({
60+
region: "us-west-2",
61+
credentials: {
62+
accessKeyId: "CLIENT_TEST",
63+
secretAccessKey: "CLIENT_TEST",
64+
},
65+
});
5266
client.middlewareStack.add(endpointValidator, { step: "build", priority: "low" });
5367
const result: any = await client.putObject({
5468
Bucket: "arn:aws:s3:us-west-2:123456789012:accesspoint:myendpoint",
@@ -151,6 +165,10 @@ describe("Throw 200 response", () => {
151165

152166
const client = new S3({
153167
region: "us-west-2",
168+
credentials: {
169+
accessKeyId: "CLIENT_TEST",
170+
secretAccessKey: "CLIENT_TEST",
171+
},
154172
requestHandler: {
155173
handle: async () => ({
156174
response,
@@ -228,7 +246,13 @@ describe("regional endpoints", () => {
228246
};
229247

230248
it("should use regional endpoints if region is us-east-1", async () => {
231-
const client = new S3({ region: "us-east-1" });
249+
const client = new S3({
250+
region: "us-east-1",
251+
credentials: {
252+
accessKeyId: "CLIENT_TEST",
253+
secretAccessKey: "CLIENT_TEST",
254+
},
255+
});
232256
client.middlewareStack.add(endpointValidator, { step: "finalizeRequest", priority: "low" });
233257
const result: any = await client.putObject({
234258
Bucket: "bucket",
@@ -239,7 +263,13 @@ describe("regional endpoints", () => {
239263
});
240264

241265
it("should use global endpoints if region is aws-global", async () => {
242-
const client = new S3({ region: "aws-global" });
266+
const client = new S3({
267+
region: "aws-global",
268+
credentials: {
269+
accessKeyId: "CLIENT_TEST",
270+
secretAccessKey: "CLIENT_TEST",
271+
},
272+
});
243273
client.middlewareStack.add(endpointValidator, { step: "finalizeRequest", priority: "low" });
244274
const result: any = await client.putObject({
245275
Bucket: "bucket",
@@ -263,7 +293,14 @@ describe("signing", () => {
263293
},
264294
};
265295

266-
const client = new S3({ requestHandler });
296+
const client = new S3({
297+
region: "us-west-2",
298+
credentials: {
299+
accessKeyId: "CLIENT_TEST",
300+
secretAccessKey: "CLIENT_TEST",
301+
},
302+
requestHandler,
303+
});
267304
return await client.putObject({
268305
Bucket: "bucket",
269306
Key: "some file.txt",

clients/client-s3/test/unit/dotSegmentInUriLabel.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
42
import { HttpHandlerOptions } from "@smithy/types";
3+
import { describe, expect, test as it } from "vitest";
4+
55
import { S3 } from "../../src/S3";
66

77
/**
@@ -25,6 +25,7 @@ class RequestSerializationTestHandler implements HttpHandler {
2525

2626
describe("Dot Segment in URI Label", () => {
2727
const client = new S3({
28+
region: "us-west-2",
2829
credentials: { accessKeyId: "mockAccessKeyId", secretAccessKey: "mockSecretAccessKey" },
2930
requestHandler: new RequestSerializationTestHandler(),
3031
});

clients/client-s3/test/unit/flexibleChecksums.spec.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { ChecksumAlgorithm } from "@aws-sdk/middleware-flexible-checksums";
42
import { HttpRequest } from "@smithy/protocol-http";
53
import { BuildMiddleware } from "@smithy/types";
64
import { Readable } from "stream";
5+
import { describe, expect, test as it } from "vitest";
76

8-
import { S3, ChecksumAlgorithm as Algo } from "../../src/index";
7+
import { ChecksumAlgorithm as Algo, S3 } from "../../src/index";
98

109
describe("Flexible Checksums", () => {
1110
const testCases = [
@@ -55,7 +54,13 @@ describe("Flexible Checksums", () => {
5554
return { output: {} as any, response: {} as any };
5655
};
5756

58-
const client = new S3({});
57+
const client = new S3({
58+
region: "us-west-2",
59+
credentials: {
60+
accessKeyId: "CLIENT_TEST",
61+
secretAccessKey: "CLIENT_TEST",
62+
},
63+
});
5964
client.middlewareStack.addRelativeTo(requestChecksumValidator, {
6065
relation: "after",
6166
toMiddleware: "flexibleChecksumsMiddleware",
@@ -89,7 +94,13 @@ describe("Flexible Checksums", () => {
8994
return { output: {} as any, response: {} as any };
9095
};
9196

92-
const client = new S3({});
97+
const client = new S3({
98+
region: "us-west-2",
99+
credentials: {
100+
accessKeyId: "CLIENT_TEST",
101+
secretAccessKey: "CLIENT_TEST",
102+
},
103+
});
93104
client.middlewareStack.addRelativeTo(requestChecksumValidator, {
94105
relation: "after",
95106
toMiddleware: "flexibleChecksumsMiddleware",
@@ -133,7 +144,13 @@ describe("Flexible Checksums", () => {
133144
};
134145
};
135146

136-
const client = new S3({});
147+
const client = new S3({
148+
region: "us-west-2",
149+
credentials: {
150+
accessKeyId: "CLIENT_TEST",
151+
secretAccessKey: "CLIENT_TEST",
152+
},
153+
});
137154
client.middlewareStack.addRelativeTo(responseChecksumValidator, {
138155
relation: "after",
139156
toMiddleware: "flexibleChecksumsMiddleware",

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import { test as it, afterAll, describe, expect } from "vitest";
2-
31
import { createReadStream } from "fs";
42
import { join } from "path";
3+
import { afterAll, describe, expect, test as it } from "vitest";
54

65
import { TranscribeStreaming } from "../src/index";
76
const audio = createReadStream(join(__dirname, "numbers.wav"));
87

98
describe("TranscribeStream client", () => {
10-
const client = new TranscribeStreaming({});
9+
const client = new TranscribeStreaming({
10+
region: "us-west-2",
11+
credentials: {
12+
accessKeyId: "CLIENT_TEST",
13+
secretAccessKey: "CLIENT_TEST",
14+
},
15+
});
1116
afterAll(() => {
1217
client.destroy();
1318
});

0 commit comments

Comments
 (0)