Skip to content

Commit

Permalink
test: throw final error in turbo script (#6594)
Browse files Browse the repository at this point in the history
* 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 <16024985+trivikr@users.noreply.github.com>
  • Loading branch information
kuhe and trivikr authored Oct 29, 2024
1 parent 28ffd0a commit 19abef7
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ describe("middleware-eventstream", () => {

describe(RekognitionStreaming.name, () => {
it("should set streaming headers", async () => {
const client = new RekognitionStreaming({ region: "us-west-2", logger });
const client = new RekognitionStreaming({
region: "us-west-2",
logger,
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});

requireRequestsFrom(client).toMatch({
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe("middleware-flexible-checksums", () => {

requireRequestsFrom(client).toMatch({
headers: {
"user-agent": new RegExp(`(.*?) m\/${id},E$`),
"user-agent": new RegExp(`(.*?) m\/(.*?)${id}(.*?)$`),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("middleware-s3-express", () => {

requireRequestsFrom(client).toMatch({
headers: {
"user-agent": /(.*?) m\/J,E$/,
"user-agent": /(.*?) m\/(.*?)J(.*?)$/,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("middleware-user-agent", () => {
describe("features", () => {
it("should detect DDB mapper, account id, and account id mode", async () => {
const client = new DynamoDB({
region: "us-west-2",
accountIdEndpointMode: async () => "required" as const,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ describe("middleware-websocket", () => {
const client = new RekognitionStreaming({
region: "us-west-2",
logger,
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
protocol: "wss:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { test as it, describe, expect } from "vitest";

import { S3Control } from "@aws-sdk/client-s3-control";
import { describe, expect, test as it } from "vitest";

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

describe("middleware-apply-body-checksum", () => {
describe(S3Control.name, () => {
it("should add body-checksum", async () => {
const client = new S3Control({ region: "us-west-2" });
const client = new S3Control({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-md5": /^.{22}(==)?$/i,
Expand Down
43 changes: 36 additions & 7 deletions private/aws-middleware-test/src/middleware-content-length.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { test as it, describe, expect } from "vitest";

import { AccessAnalyzer } from "@aws-sdk/client-accessanalyzer";
import { S3 } from "@aws-sdk/client-s3";
import { XRay } from "@aws-sdk/client-xray";
import { describe, expect, test as it } from "vitest";

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

describe("middleware-content-length", () => {
describe(AccessAnalyzer.name, () => {
it("should not add content-length if no body", async () => {
const client = new AccessAnalyzer({ region: "us-west-2" });
const client = new AccessAnalyzer({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-length": /undefined/,
Expand All @@ -24,7 +29,13 @@ describe("middleware-content-length", () => {
});

it("should add content-length if body present", async () => {
const client = new AccessAnalyzer({ region: "us-west-2" });
const client = new AccessAnalyzer({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-length": /106/,
Expand All @@ -42,7 +53,13 @@ describe("middleware-content-length", () => {

describe(S3.name, () => {
it("should not add content-length if no body", async () => {
const client = new S3({ region: "us-west-2" });
const client = new S3({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-length": /undefined/,
Expand All @@ -58,7 +75,13 @@ describe("middleware-content-length", () => {
});

it("should add content-length if body present", async () => {
const client = new S3({ region: "us-west-2" });
const client = new S3({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-length": /4/,
Expand All @@ -77,7 +100,13 @@ describe("middleware-content-length", () => {

describe(XRay.name, () => {
it("should add content-length if body present", async () => {
const client = new XRay({ region: "us-west-2" });
const client = new XRay({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
headers: {
"content-length": /24/,
Expand Down
11 changes: 9 additions & 2 deletions private/aws-middleware-test/src/middleware-endpoint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test as it, describe, expect } from "vitest";

import { S3 } from "@aws-sdk/client-s3";
import { S3Control } from "@aws-sdk/client-s3-control";
import { describe, expect, test as it } from "vitest";

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

Expand All @@ -13,6 +12,10 @@ describe("middleware-endpoint", () => {
it("should resolve endpoints", async () => {
const client = new S3({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
useFipsEndpoint: true,
useDualstackEndpoint: true,
useArnRegion: true,
Expand All @@ -33,6 +36,10 @@ describe("middleware-endpoint", () => {
it("should resolve endpoints", async () => {
const client = new S3Control({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
useFipsEndpoint: true,
useDualstackEndpoint: true,
useArnRegion: true,
Expand Down
7 changes: 5 additions & 2 deletions private/aws-middleware-test/src/middleware-retry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { test as it, describe, expect } from "vitest";

import { Lambda } from "@aws-sdk/client-lambda";
import { describe, expect, test as it } from "vitest";

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

Expand All @@ -9,6 +8,10 @@ describe("middleware-retry", () => {
it("should set retry headers", async () => {
const client = new Lambda({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});

requireRequestsFrom(client).toMatch({
Expand Down
35 changes: 29 additions & 6 deletions private/aws-middleware-test/src/middleware-serde.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { test as it, describe } from "vitest";

import { EC2 } from "@aws-sdk/client-ec2";
import { S3 } from "@aws-sdk/client-s3";
import { SageMaker } from "@aws-sdk/client-sagemaker";
import { SageMakerRuntime } from "@aws-sdk/client-sagemaker-runtime";
import { describe, test as it } from "vitest";

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

describe("middleware-serde", () => {
describe(S3.name, () => {
it("should serialize xml", async () => {
const client = new S3({ region: "us-west-2" });
const client = new S3({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
method: "PUT",
hostname: "s3.us-west-2.amazonaws.com",
Expand Down Expand Up @@ -55,7 +60,13 @@ describe("middleware-serde", () => {

describe(EC2.name, () => {
it("should serialize query", async () => {
const client = new EC2({ region: "us-west-2" });
const client = new EC2({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
method: "POST",
hostname: "ec2.us-west-2.amazonaws.com",
Expand All @@ -79,7 +90,13 @@ describe("middleware-serde", () => {

describe(SageMaker.name, () => {
it("should serialize json", async () => {
const client = new SageMaker({ region: "us-west-2" });
const client = new SageMaker({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
method: "POST",
hostname: "api.sagemaker.us-west-2.amazonaws.com",
Expand All @@ -102,7 +119,13 @@ describe("middleware-serde", () => {

describe(SageMakerRuntime.name, () => {
it("should serialize json", async () => {
const client = new SageMakerRuntime({ region: "us-west-2" });
const client = new SageMakerRuntime({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
method: "POST",
hostname: "runtime.sagemaker.us-west-2.amazonaws.com",
Expand Down
15 changes: 12 additions & 3 deletions private/aws-middleware-test/src/util-stream.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { test as it, describe, expect } from "vitest";

import { Lambda } from "@aws-sdk/client-lambda";
import { HttpHandler, HttpResponse } from "@smithy/protocol-http";
import { HttpRequest as IHttpRequest } from "@smithy/types";
import { Uint8ArrayBlobAdapter } from "@smithy/util-stream";
import { fromUtf8 } from "@smithy/util-utf8";
import { Readable } from "stream";
import { describe, expect, test as it } from "vitest";

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

describe("util-stream", () => {
describe(Lambda.name, () => {
it("should be uniform between string and Uint8Array payloads", async () => {
const client = new Lambda({ region: "us-west-2" });
const client = new Lambda({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});
requireRequestsFrom(client).toMatch({
method: "POST",
hostname: "lambda.us-west-2.amazonaws.com",
Expand Down Expand Up @@ -54,6 +59,10 @@ describe("util-stream", () => {

const lambda = new Lambda({
region: "us-west-2",
credentials: {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
},
});

requireRequestsFrom(lambda).toMatch({
Expand Down
4 changes: 2 additions & 2 deletions private/aws-util-test/src/clients/Weather.integ.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { test as it, describe, expect } from "vitest";

import { Weather } from "@aws-sdk/weather";
import { describe, expect, test as it } from "vitest";

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

Expand All @@ -12,6 +11,7 @@ describe(Weather.name, () => {
secretAccessKey: "",
},
endpoint: "https://localhost",
region: "us-west-2",
});

requireRequestsFrom(client).toMatch({
Expand Down
Loading

0 comments on commit 19abef7

Please sign in to comment.