-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(middleware): integ tests for sdk clients (#4686)
- Loading branch information
Showing
23 changed files
with
705 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/middleware-sdk-api-gateway/src/middleware-sdk-api-gateway.integ.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { APIGateway } from "@aws-sdk/client-api-gateway"; | ||
|
||
import { requireRequestsFrom } from "../../../private/aws-util-test/src"; | ||
|
||
describe("middleware-sdk-api-gateway", () => { | ||
describe(APIGateway.name, () => { | ||
it("should add accept header", async () => { | ||
const client = new APIGateway({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
headers: { | ||
accept: "application/json", | ||
}, | ||
}); | ||
|
||
await client.getApiKeys({}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
packages/middleware-sdk-glacier/src/middleware-sdk-glacier.integ.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Glacier } from "@aws-sdk/client-glacier"; | ||
|
||
import { requireRequestsFrom } from "../../../private/aws-util-test/src"; | ||
|
||
describe("middleware-sdk-glacier", () => { | ||
describe(Glacier.name, () => { | ||
it("should set a default account id", async () => { | ||
const client = new Glacier({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
path: `/-/vaults`, | ||
}); | ||
|
||
await client.listVaults({ | ||
accountId: undefined, | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
|
||
it("should not override account id", async () => { | ||
const client = new Glacier({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
path: `/1234/vaults`, | ||
}); | ||
|
||
await client.listVaults({ | ||
accountId: "1234", | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
|
||
describe("headers", () => { | ||
it("should set checksum and api version headers", async () => { | ||
const client = new Glacier({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
headers: { | ||
"x-amz-glacier-version": "2012-06-01", | ||
"x-amz-content-sha256": "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589", | ||
"x-amz-sha256-tree-hash": "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589", | ||
}, | ||
}); | ||
|
||
await client.uploadArchive({ | ||
vaultName: "vault", | ||
accountId: "1234", | ||
body: Buffer.from("abcd"), | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/middleware-sdk-machinelearning/src/middleware-sdk-machinelearning.integ.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { MachineLearning } from "@aws-sdk/client-machine-learning"; | ||
|
||
import { requireRequestsFrom } from "../../../private/aws-util-test/src"; | ||
|
||
describe("middleware-sdk-machine-learning", () => { | ||
describe(MachineLearning.name, () => { | ||
it("should use the input predict endpoint", async () => { | ||
const client = new MachineLearning({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
hostname: "predict-custom-endpoint.us-west-2.amazonaws.com", | ||
protocol: "https:", | ||
path: "/my-path", | ||
query: { | ||
apples: "oranges", | ||
}, | ||
}); | ||
|
||
await client.predict({ | ||
PredictEndpoint: `https://predict-custom-endpoint.us-west-2.amazonaws.com/my-path?apples=oranges`, | ||
MLModelId: "1", | ||
Record: { | ||
hello: "world", | ||
}, | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/middleware-sdk-route53/src/middleware-sdk-route53.integ.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Route53 } from "@aws-sdk/client-route-53"; | ||
import { XMLParser } from "fast-xml-parser"; | ||
|
||
import { requireRequestsFrom } from "../../../private/aws-util-test/src"; | ||
|
||
describe("middleware-sdk-route53", () => { | ||
describe(Route53.name, () => { | ||
it("should normalize param names HostedZoneId", async () => { | ||
const client = new Route53({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
body: /<HostedZoneId>my-zone<\/HostedZoneId>/, | ||
}); | ||
|
||
await client.createKeySigningKey({ | ||
HostedZoneId: "/hostedzone/my-zone", | ||
CallerReference: "abcd", | ||
KeyManagementServiceArn: "arn", | ||
Name: "name", | ||
Status: "ACTIVE", | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
|
||
it("should normalize param names DelegationSetId", async () => { | ||
const client = new Route53({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
body: /<DelegationSetId>my-set<\/DelegationSetId>/, | ||
}); | ||
|
||
await client.createHostedZone({ | ||
CallerReference: "abcd", | ||
Name: "name", | ||
DelegationSetId: "/delegationset/my-set", | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
|
||
it("should normalize param names Id", async () => { | ||
const client = new Route53({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
path: "/2013-04-01/change/my-change", | ||
}); | ||
|
||
await client.getChange({ | ||
Id: "/change/my-change", | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
|
||
it("should update change resource record sets request", async () => { | ||
const client = new Route53({ | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(client).toMatch({ | ||
body(raw) { | ||
const parsed = new XMLParser().parse(raw); | ||
expect( | ||
parsed.ChangeResourceRecordSetsRequest.ChangeBatch.Changes.Change.ResourceRecordSet.AliasTarget.HostedZoneId | ||
).toMatch(/^my-zone$/); | ||
}, | ||
}); | ||
|
||
await client.changeResourceRecordSets({ | ||
HostedZoneId: "zone", | ||
ChangeBatch: { | ||
Changes: [ | ||
{ | ||
Action: "UPSERT", | ||
ResourceRecordSet: { | ||
Name: "name", | ||
Type: "CNAME", | ||
AliasTarget: { | ||
HostedZoneId: "/hostedzone/my-zone", | ||
DNSName: "dns-name", | ||
EvaluateTargetHealth: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
expect.hasAssertions(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.