Skip to content

Commit 6b988d4

Browse files
committed
test(aws-middleware-test): add mock creds for integration tests
1 parent fed1215 commit 6b988d4

File tree

6 files changed

+99
-23
lines changed

6 files changed

+99
-23
lines changed

private/aws-middleware-test/src/middleware-apply-body-checksum.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, describe, expect } from "vitest";
2-
31
import { S3Control } from "@aws-sdk/client-s3-control";
2+
import { describe, expect, test as it } from "vitest";
43

54
import { requireRequestsFrom } from "../../aws-util-test/src";
65

76
describe("middleware-apply-body-checksum", () => {
87
describe(S3Control.name, () => {
98
it("should add body-checksum", async () => {
10-
const client = new S3Control({ region: "us-west-2" });
9+
const client = new S3Control({
10+
region: "us-west-2",
11+
credentials: {
12+
accessKeyId: "INTEG",
13+
secretAccessKey: "INTEG",
14+
},
15+
});
1116
requireRequestsFrom(client).toMatch({
1217
headers: {
1318
"content-md5": /^.{22}(==)?$/i,

private/aws-middleware-test/src/middleware-content-length.spec.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { AccessAnalyzer } from "@aws-sdk/client-accessanalyzer";
42
import { S3 } from "@aws-sdk/client-s3";
53
import { XRay } from "@aws-sdk/client-xray";
4+
import { describe, expect, test as it } from "vitest";
65

76
import { requireRequestsFrom } from "../../../private/aws-util-test/src";
87

98
describe("middleware-content-length", () => {
109
describe(AccessAnalyzer.name, () => {
1110
it("should not add content-length if no body", async () => {
12-
const client = new AccessAnalyzer({ region: "us-west-2" });
11+
const client = new AccessAnalyzer({
12+
region: "us-west-2",
13+
credentials: {
14+
accessKeyId: "INTEG",
15+
secretAccessKey: "INTEG",
16+
},
17+
});
1318
requireRequestsFrom(client).toMatch({
1419
headers: {
1520
"content-length": /undefined/,
@@ -24,7 +29,13 @@ describe("middleware-content-length", () => {
2429
});
2530

2631
it("should add content-length if body present", async () => {
27-
const client = new AccessAnalyzer({ region: "us-west-2" });
32+
const client = new AccessAnalyzer({
33+
region: "us-west-2",
34+
credentials: {
35+
accessKeyId: "INTEG",
36+
secretAccessKey: "INTEG",
37+
},
38+
});
2839
requireRequestsFrom(client).toMatch({
2940
headers: {
3041
"content-length": /106/,
@@ -42,7 +53,13 @@ describe("middleware-content-length", () => {
4253

4354
describe(S3.name, () => {
4455
it("should not add content-length if no body", async () => {
45-
const client = new S3({ region: "us-west-2" });
56+
const client = new S3({
57+
region: "us-west-2",
58+
credentials: {
59+
accessKeyId: "INTEG",
60+
secretAccessKey: "INTEG",
61+
},
62+
});
4663
requireRequestsFrom(client).toMatch({
4764
headers: {
4865
"content-length": /undefined/,
@@ -58,7 +75,13 @@ describe("middleware-content-length", () => {
5875
});
5976

6077
it("should add content-length if body present", async () => {
61-
const client = new S3({ region: "us-west-2" });
78+
const client = new S3({
79+
region: "us-west-2",
80+
credentials: {
81+
accessKeyId: "INTEG",
82+
secretAccessKey: "INTEG",
83+
},
84+
});
6285
requireRequestsFrom(client).toMatch({
6386
headers: {
6487
"content-length": /4/,
@@ -77,7 +100,13 @@ describe("middleware-content-length", () => {
77100

78101
describe(XRay.name, () => {
79102
it("should add content-length if body present", async () => {
80-
const client = new XRay({ region: "us-west-2" });
103+
const client = new XRay({
104+
region: "us-west-2",
105+
credentials: {
106+
accessKeyId: "INTEG",
107+
secretAccessKey: "INTEG",
108+
},
109+
});
81110
requireRequestsFrom(client).toMatch({
82111
headers: {
83112
"content-length": /24/,

private/aws-middleware-test/src/middleware-endpoint.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { S3 } from "@aws-sdk/client-s3";
42
import { S3Control } from "@aws-sdk/client-s3-control";
3+
import { describe, expect, test as it } from "vitest";
54

65
import { requireRequestsFrom } from "../../aws-util-test/src";
76

@@ -13,6 +12,10 @@ describe("middleware-endpoint", () => {
1312
it("should resolve endpoints", async () => {
1413
const client = new S3({
1514
region: "us-west-2",
15+
credentials: {
16+
accessKeyId: "INTEG",
17+
secretAccessKey: "INTEG",
18+
},
1619
useFipsEndpoint: true,
1720
useDualstackEndpoint: true,
1821
useArnRegion: true,
@@ -33,6 +36,10 @@ describe("middleware-endpoint", () => {
3336
it("should resolve endpoints", async () => {
3437
const client = new S3Control({
3538
region: "us-west-2",
39+
credentials: {
40+
accessKeyId: "INTEG",
41+
secretAccessKey: "INTEG",
42+
},
3643
useFipsEndpoint: true,
3744
useDualstackEndpoint: true,
3845
useArnRegion: true,

private/aws-middleware-test/src/middleware-retry.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { Lambda } from "@aws-sdk/client-lambda";
2+
import { describe, expect, test as it } from "vitest";
43

54
import { requireRequestsFrom } from "../../aws-util-test/src";
65

@@ -9,6 +8,10 @@ describe("middleware-retry", () => {
98
it("should set retry headers", async () => {
109
const client = new Lambda({
1110
region: "us-west-2",
11+
credentials: {
12+
accessKeyId: "INTEG",
13+
secretAccessKey: "INTEG",
14+
},
1215
});
1316

1417
requireRequestsFrom(client).toMatch({

private/aws-middleware-test/src/middleware-serde.spec.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import { test as it, describe } from "vitest";
2-
31
import { EC2 } from "@aws-sdk/client-ec2";
42
import { S3 } from "@aws-sdk/client-s3";
53
import { SageMaker } from "@aws-sdk/client-sagemaker";
64
import { SageMakerRuntime } from "@aws-sdk/client-sagemaker-runtime";
5+
import { describe, test as it } from "vitest";
76

87
import { requireRequestsFrom } from "../../aws-util-test/src";
98

109
describe("middleware-serde", () => {
1110
describe(S3.name, () => {
1211
it("should serialize xml", async () => {
13-
const client = new S3({ region: "us-west-2" });
12+
const client = new S3({
13+
region: "us-west-2",
14+
credentials: {
15+
accessKeyId: "INTEG",
16+
secretAccessKey: "INTEG",
17+
},
18+
});
1419
requireRequestsFrom(client).toMatch({
1520
method: "PUT",
1621
hostname: "s3.us-west-2.amazonaws.com",
@@ -55,7 +60,13 @@ describe("middleware-serde", () => {
5560

5661
describe(EC2.name, () => {
5762
it("should serialize query", async () => {
58-
const client = new EC2({ region: "us-west-2" });
63+
const client = new EC2({
64+
region: "us-west-2",
65+
credentials: {
66+
accessKeyId: "INTEG",
67+
secretAccessKey: "INTEG",
68+
},
69+
});
5970
requireRequestsFrom(client).toMatch({
6071
method: "POST",
6172
hostname: "ec2.us-west-2.amazonaws.com",
@@ -79,7 +90,13 @@ describe("middleware-serde", () => {
7990

8091
describe(SageMaker.name, () => {
8192
it("should serialize json", async () => {
82-
const client = new SageMaker({ region: "us-west-2" });
93+
const client = new SageMaker({
94+
region: "us-west-2",
95+
credentials: {
96+
accessKeyId: "INTEG",
97+
secretAccessKey: "INTEG",
98+
},
99+
});
83100
requireRequestsFrom(client).toMatch({
84101
method: "POST",
85102
hostname: "api.sagemaker.us-west-2.amazonaws.com",
@@ -102,7 +119,13 @@ describe("middleware-serde", () => {
102119

103120
describe(SageMakerRuntime.name, () => {
104121
it("should serialize json", async () => {
105-
const client = new SageMakerRuntime({ region: "us-west-2" });
122+
const client = new SageMakerRuntime({
123+
region: "us-west-2",
124+
credentials: {
125+
accessKeyId: "INTEG",
126+
secretAccessKey: "INTEG",
127+
},
128+
});
106129
requireRequestsFrom(client).toMatch({
107130
method: "POST",
108131
hostname: "runtime.sagemaker.us-west-2.amazonaws.com",

private/aws-middleware-test/src/util-stream.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { Lambda } from "@aws-sdk/client-lambda";
42
import { HttpHandler, HttpResponse } from "@smithy/protocol-http";
53
import { HttpRequest as IHttpRequest } from "@smithy/types";
64
import { Uint8ArrayBlobAdapter } from "@smithy/util-stream";
75
import { fromUtf8 } from "@smithy/util-utf8";
86
import { Readable } from "stream";
7+
import { describe, expect, test as it } from "vitest";
98

109
import { requireRequestsFrom } from "../../aws-util-test/src";
1110

1211
describe("util-stream", () => {
1312
describe(Lambda.name, () => {
1413
it("should be uniform between string and Uint8Array payloads", async () => {
15-
const client = new Lambda({ region: "us-west-2" });
14+
const client = new Lambda({
15+
region: "us-west-2",
16+
credentials: {
17+
accessKeyId: "INTEG",
18+
secretAccessKey: "INTEG",
19+
},
20+
});
1621
requireRequestsFrom(client).toMatch({
1722
method: "POST",
1823
hostname: "lambda.us-west-2.amazonaws.com",
@@ -54,6 +59,10 @@ describe("util-stream", () => {
5459

5560
const lambda = new Lambda({
5661
region: "us-west-2",
62+
credentials: {
63+
accessKeyId: "INTEG",
64+
secretAccessKey: "INTEG",
65+
},
5766
});
5867

5968
requireRequestsFrom(lambda).toMatch({

0 commit comments

Comments
 (0)