diff --git a/packages/core/src/submodules/account-id-endpoint/account-id-endpoint.integ.spec.ts b/packages/core/integ/account-id-endpoint.integ.spec.ts similarity index 100% rename from packages/core/src/submodules/account-id-endpoint/account-id-endpoint.integ.spec.ts rename to packages/core/integ/account-id-endpoint.integ.spec.ts diff --git a/packages/core/integ/configuration-file/aws-config-file.integ.spec.ts b/packages/core/integ/configuration-file/aws-config-file.integ.spec.ts new file mode 100644 index 0000000000000..1b1ee2c59c4bd --- /dev/null +++ b/packages/core/integ/configuration-file/aws-config-file.integ.spec.ts @@ -0,0 +1,45 @@ +import { afterAll, beforeEach, describe, expect, test as it } from "vitest"; +import { S3 } from "@aws-sdk/client-s3"; +import path from "node:path"; +import type { Provider } from "@smithy/types"; + +describe("defaults mode", () => { + const snapshot = { + ...process.env, + }; + + beforeEach(async () => { + process.env = {}; + }); + + afterAll(async () => { + process.env = snapshot; + }); + + it("should load various client configuration options from file with default profile", async () => { + process.env.AWS_CONFIG_FILE = path.join(__dirname, "mock-aws-config"); + + const client = new S3({}); + + expect(await client.config.region()).toEqual("us-west-2"); + }); + + it("should load various client configuration options from specific profile", async () => { + process.env.AWS_CONFIG_FILE = path.join(__dirname, "mock-aws-config"); + + const client = new S3({ + profile: "abc", + }); + + expect(await client.config.region()).toEqual("ap-northeast-1"); + expect(await (client.config.retryMode as Provider)()).toEqual("adaptive"); + expect(await (client.config.disableS3ExpressSessionAuth as Provider)()).toEqual(true); + expect(await client.config.maxAttempts()).toEqual(33); + expect(await client.config.requestChecksumCalculation()).toEqual("WHEN_REQUIRED"); + expect(await client.config.sigv4aSigningRegionSet()).toEqual(["*", "*", "us-west-2"]); + expect(await client.config.useFipsEndpoint()).toEqual(true); + expect(await (client.config.useArnRegion as Provider)()).toEqual(true); + expect(await client.config.useDualstackEndpoint()).toEqual(true); + expect(await client.config.userAgentAppId()).toEqual("blargh"); + }); +}); diff --git a/packages/core/integ/configuration-file/mock-aws-config b/packages/core/integ/configuration-file/mock-aws-config new file mode 100644 index 0000000000000..1f77f160eaea8 --- /dev/null +++ b/packages/core/integ/configuration-file/mock-aws-config @@ -0,0 +1,17 @@ +[profile empty] + +[default] +region = us-west-2 +output = json + +[profile abc] +region = ap-northeast-1 +retry_mode = adaptive +s3_disable_express_session_auth = true +max_attempts = 33 +request_checksum_calculation = when_required +sigv4a_signing_region_set = *,*,us-west-2 +use_fips_endpoint = true +s3_use_arn_region = true +use_dualstack_endpoint = true +sdk-ua-app-id = blargh diff --git a/packages/core/integ/defaults-mode.integ.spec.ts b/packages/core/integ/defaults-mode.integ.spec.ts new file mode 100644 index 0000000000000..6175a0d458720 --- /dev/null +++ b/packages/core/integ/defaults-mode.integ.spec.ts @@ -0,0 +1,94 @@ +import { describe, test as it, expect, beforeEach, afterAll } from "vitest"; + +import { CloudWatch } from "@aws-sdk/client-cloudwatch"; +import type { DefaultsMode } from "@smithy/smithy-client"; +import type { NodeHttpHandlerOptions, Provider } from "@smithy/types"; +import type { Agent as hAgent } from "http"; +import type { Agent as hsAgent } from "https"; + +describe("defaults mode", () => { + const snapshot = { + AWS_EXECUTION_ENV: process.env.AWS_EXECUTION_ENV, + AWS_REGION: process.env.AWS_REGION, + AWS_DEFAULT_REGION: process.env.AWS_DEFAULT_REGION, + AWS_DEFAULTS_MODE: process.env.AWS_DEFAULTS_MODE, + }; + + beforeEach(async () => { + delete process.env.AWS_EXECUTION_ENV; + delete process.env.AWS_REGION; + delete process.env.AWS_DEFAULT_REGION; + delete process.env.AWS_DEFAULTS_MODE; + }); + + afterAll(async () => { + Object.assign(process.env, snapshot); + }); + + const sharedConfig = { + credentials: { + accessKeyId: "INTEG", + secretAccessKey: "INTEG", + }, + region: "ap-northeast-1", + }; + + async function assertCrossRegion(client: CloudWatch) { + expect(await (client.config.defaultsMode as Provider)()).toEqual("cross-region"); + const handler = client.config.requestHandler; + + type ResolvedNodeHttpHandlerConfig = Omit & { + httpAgent: hAgent; + httpsAgent: hsAgent; + }; + + const config = await ( + handler as unknown as { + configProvider: Promise; + } + ).configProvider; + + expect(config).toMatchObject({ + connectionTimeout: 3100, + }); + } + + it("should set a higher timeout due to cross-region defaults mode when auto-detected (ENV)", async () => { + process.env.AWS_DEFAULTS_MODE = "auto"; + process.env.AWS_EXECUTION_ENV = "INTEGRATION_TEST"; + process.env.AWS_DEFAULT_REGION = "us-east-1"; + + const client = new CloudWatch(sharedConfig); + + await assertCrossRegion(client); + }); + + it("should set a higher timeout due to cross-region defaults mode when auto-detected (client-config)", async () => { + process.env.AWS_EXECUTION_ENV = "INTEGRATION_TEST"; + process.env.AWS_DEFAULT_REGION = "us-east-1"; + + const client = new CloudWatch({ + ...sharedConfig, + defaultsMode: "auto", + }); + + await assertCrossRegion(client); + }); + + it("should set a higher timeout when cross region defaults-mode is set (ENV)", async () => { + process.env.AWS_DEFAULTS_MODE = "cross-region"; + + const client = new CloudWatch(sharedConfig); + + await assertCrossRegion(client); + }); + + it("should set a higher timeout when cross region defaults-mode is set (client-config)", async () => { + const client = new CloudWatch({ + ...sharedConfig, + defaultsMode: "cross-region", + }); + + await assertCrossRegion(client); + }); +}); diff --git a/packages/core/src/submodules/protocols/lazy-json-string.integ.spec.ts b/packages/core/integ/lazy-json-string.integ.spec.ts similarity index 100% rename from packages/core/src/submodules/protocols/lazy-json-string.integ.spec.ts rename to packages/core/integ/lazy-json-string.integ.spec.ts diff --git a/packages/core/src/submodules/client/pagination.integ.spec.ts b/packages/core/integ/pagination.integ.spec.ts similarity index 100% rename from packages/core/src/submodules/client/pagination.integ.spec.ts rename to packages/core/integ/pagination.integ.spec.ts diff --git a/packages/core/src/submodules/protocols/request-compression.integ.spec.ts b/packages/core/integ/request-compression.integ.spec.ts similarity index 100% rename from packages/core/src/submodules/protocols/request-compression.integ.spec.ts rename to packages/core/integ/request-compression.integ.spec.ts diff --git a/packages/core/src/submodules/client/waiters.integ.spec.ts b/packages/core/integ/waiters.integ.spec.ts similarity index 100% rename from packages/core/src/submodules/client/waiters.integ.spec.ts rename to packages/core/integ/waiters.integ.spec.ts