Skip to content

Commit 19abef7

Browse files
kuhetrivikr
andauthored
test: throw final error in turbo script (#6594)
* test: throw final error in turbo script * test: add region * test(middleware-user-agent): add client region in integ test * test(middleware-websocket): set mock credentials * chore(scripts): no retry in turbo * test(aws-util-test): delete AWS env vars, set mock credentials in integ tests * test(aws-middleware-test): add mock creds for integration tests * test(aws-util-test): add httpAuthScheme mocking for integ tests * test: override selected httpAuthScheme.identity in integration tests * test: override signer credential provider in integration * test: use static credentials in integration * test: remove unused --------- Co-authored-by: Kamat, Trivikram <[email protected]>
1 parent 28ffd0a commit 19abef7

File tree

14 files changed

+141
-61
lines changed

14 files changed

+141
-61
lines changed

packages/middleware-eventstream/src/middleware-eventstream.integ.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ describe("middleware-eventstream", () => {
4040

4141
describe(RekognitionStreaming.name, () => {
4242
it("should set streaming headers", async () => {
43-
const client = new RekognitionStreaming({ region: "us-west-2", logger });
43+
const client = new RekognitionStreaming({
44+
region: "us-west-2",
45+
logger,
46+
credentials: {
47+
accessKeyId: "INTEG",
48+
secretAccessKey: "INTEG",
49+
},
50+
});
4451

4552
requireRequestsFrom(client).toMatch({
4653
headers: {

packages/middleware-flexible-checksums/src/middleware-flexible-checksums.integ.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe("middleware-flexible-checksums", () => {
138138

139139
requireRequestsFrom(client).toMatch({
140140
headers: {
141-
"user-agent": new RegExp(`(.*?) m\/${id},E$`),
141+
"user-agent": new RegExp(`(.*?) m\/(.*?)${id}(.*?)$`),
142142
},
143143
});
144144

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe("middleware-s3-express", () => {
9494

9595
requireRequestsFrom(client).toMatch({
9696
headers: {
97-
"user-agent": /(.*?) m\/J,E$/,
97+
"user-agent": /(.*?) m\/(.*?)J(.*?)$/,
9898
},
9999
});
100100

packages/middleware-user-agent/src/middleware-user-agent.integ.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe("middleware-user-agent", () => {
3030
describe("features", () => {
3131
it("should detect DDB mapper, account id, and account id mode", async () => {
3232
const client = new DynamoDB({
33+
region: "us-west-2",
3334
accountIdEndpointMode: async () => "required" as const,
3435
});
3536

packages/middleware-websocket/src/middleware-websocket.integ.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ describe("middleware-websocket", () => {
1616
const client = new RekognitionStreaming({
1717
region: "us-west-2",
1818
logger,
19+
credentials: {
20+
accessKeyId: "INTEG",
21+
secretAccessKey: "INTEG",
22+
},
1923
});
2024
requireRequestsFrom(client).toMatch({
2125
protocol: "wss:",

private/aws-middleware-test/src/middleware-apply-body-checksum.spec.ts

+8-3
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

+36-7
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

+9-2
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

+5-2
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

+29-6
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

+12-3
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({

private/aws-util-test/src/clients/Weather.integ.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { test as it, describe, expect } from "vitest";
2-
31
import { Weather } from "@aws-sdk/weather";
2+
import { describe, expect, test as it } from "vitest";
43

54
import { requireRequestsFrom } from "../requests/test-http-handler";
65

@@ -12,6 +11,7 @@ describe(Weather.name, () => {
1211
secretAccessKey: "",
1312
},
1413
endpoint: "https://localhost",
14+
region: "us-west-2",
1515
});
1616

1717
requireRequestsFrom(client).toMatch({

0 commit comments

Comments
 (0)