Skip to content

Commit

Permalink
test(client-ec2): increase timeout in ec2 tests and add isob test case (
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jun 1, 2023
1 parent 4c2fd64 commit 5bafb4d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions features/ec2/step_definitions/ec2.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function copySnapshotIntegration({ encryptSource, encryptDestination } = {}) {

volId = createVolume.VolumeId;

await waitUntilVolumeAvailable({ client: srcEc2, maxWaitTime: 60 }, { VolumeIds: [volId] });
await waitUntilVolumeAvailable({ client: srcEc2, maxWaitTime: 120 }, { VolumeIds: [volId] });
const createSnapshot = await srcEc2.createSnapshot({
VolumeId: volId,
TagSpecifications: [
Expand All @@ -100,7 +100,7 @@ function copySnapshotIntegration({ encryptSource, encryptDestination } = {}) {
srcSnapId = createSnapshot.SnapshotId;

await waitUntilSnapshotCompleted(
{ client: srcEc2, maxWaitTime: 20 },
{ client: srcEc2, maxWaitTime: 120 },
{
SnapshotId: createSnapshot.SnapshotId,
}
Expand Down
56 changes: 56 additions & 0 deletions packages/middleware-sdk-ec2/src/middleware-sdk-ec2.integ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,60 @@ describe("EC2", () => {
expect.hasAssertions();
});
});

it("in us-isob-east-1, serializes PSU and DestinationRegion when Encrypted=true and KmsKeyId present", async () => {
const client = new EC2({
region: "us-isob-east-1",
});

new TestHttpHandler({
method: "POST",
hostname: "ec2.us-isob-east-1.sc2s.sgov.gov",
protocol: "https:",
query: {},
headers: {},
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("DestinationRegion")).toEqual("us-isob-east-1");
expect(parse.get("Encrypted")).toEqual("true");
expect(parse.get("KmsKeyId")).toEqual("my-kms-key");
expect(parse.get("SourceRegion")).toEqual("us-isob-east-1");
expect(parse.get("SourceSnapshotId")).toEqual("my-snapshot-id");
expect(parse.get("Action")).toEqual("CopySnapshot");
expect(parse.get("Version")).toEqual("2016-11-15");
const psu = parse.get("PresignedUrl") as string;

const matchers = [
/https\:\/\/ec2\.us-isob-east-1\.sc2s\.sgov\.gov\/\?Action=CopySnapshot/,
/DestinationRegion=us-isob-east-1/,
/Encrypted=true/,
/KmsKeyId=my-kms-key/,
/SourceRegion=us-isob-east-1/,
/SourceSnapshotId=my-snapshot-id/,
/Version=2016-11-15/,
/X-Amz-Algorithm=AWS4-HMAC-SHA256/,
/X-Amz-Credential=(.+)\%2Fus-isob-east-1\%2Fec2\%2Faws4_request/,
/X-Amz-Date=(\d{8})T(\d{6})Z/,
/X-Amz-Expires=3600(&X-Amz-Security-Token=(.+))?/,
/X-Amz-Signature=(.+)/,
/X-Amz-SignedHeaders=host/,
];

for (const matcher of matchers) {
expect(psu).toMatch(matcher);
}
},
}).watch(client);

await client.copySnapshot({
SourceSnapshotId: "my-snapshot-id",
Description: "my-description",
DestinationRegion: "us-isob-east-1",
SourceRegion: "us-isob-east-1",
Encrypted: true,
KmsKeyId: "my-kms-key",
});

expect.hasAssertions();
});
});

0 comments on commit 5bafb4d

Please sign in to comment.