-
Notifications
You must be signed in to change notification settings - Fork 634
test: add assorted integ/e2e tests #7230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
43 changes: 43 additions & 0 deletions
43
clients/client-s3/test/integ/s3-object-lambda.integ.spec.ts
This file contains hidden or 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,43 @@ | ||
import { describe, test as it } from "vitest"; | ||
|
||
import { S3 } from "@aws-sdk/client-s3"; | ||
import { AwsCredentialIdentity } from "@smithy/types"; | ||
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src"; | ||
|
||
describe("S3 Object Lambda", () => { | ||
const region = "us-west-2"; | ||
const credentials: AwsCredentialIdentity = { | ||
accessKeyId: "", | ||
secretAccessKey: "", | ||
}; | ||
|
||
it("can make a GET request to an S3 Object Lambda ARN", async () => { | ||
const s3 = new S3({ | ||
region, | ||
credentials, | ||
}); | ||
|
||
requireRequestsFrom(s3).toMatch({ | ||
hostname: "my-access-point-123456789012.s3-object-lambda.us-west-2.amazonaws.com", | ||
query: { | ||
"x-id": "GetObject", | ||
}, | ||
headers: { | ||
authorization: /=\/\d+\/us-west-2\/s3-object-lambda\/aws4_request/, | ||
}, | ||
path: "/a", | ||
}); | ||
|
||
// slash delimiter | ||
await s3.getObject({ | ||
Bucket: "arn:aws:s3-object-lambda:us-west-2:123456789012:accesspoint/my-access-point", | ||
Key: "a", | ||
}); | ||
|
||
// colon delimiter | ||
await s3.getObject({ | ||
Bucket: "arn:aws:s3-object-lambda:us-west-2:123456789012:accesspoint:my-access-point", | ||
Key: "a", | ||
}); | ||
}); | ||
}); |
This file contains hidden or 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,46 @@ | ||
import { describe, test as it, expect } from "vitest"; | ||
|
||
import { S3Client } from "@aws-sdk/client-s3"; | ||
import { LambdaClient } from "@aws-sdk/client-lambda"; | ||
import { EMRClient } from "@aws-sdk/client-emr"; | ||
import { SageMakerClient } from "@aws-sdk/client-sagemaker"; | ||
import { CloudWatchClient } from "@aws-sdk/client-cloudwatch"; | ||
import { STSClient } from "@aws-sdk/client-sts"; | ||
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; | ||
import { CloudFormationClient } from "@aws-sdk/client-cloudformation"; | ||
import { SFNClient } from "@aws-sdk/client-sfn"; | ||
|
||
const clients = [ | ||
new S3Client(), | ||
new LambdaClient(), | ||
new EMRClient(), | ||
new SageMakerClient(), | ||
new CloudFormationClient(), | ||
new CloudWatchClient(), | ||
new STSClient(), | ||
new DynamoDBClient(), | ||
new SFNClient(), | ||
]; | ||
|
||
const serviceIds = [ | ||
"S3", | ||
"Lambda", | ||
"EMR", | ||
"SageMaker", | ||
"CloudFormation", | ||
"CloudWatch", | ||
"STS", | ||
"DynamoDB", | ||
"SFN", | ||
] as string[]; | ||
|
||
describe("service ids (various clients)", () => { | ||
for (const [i, client] of Object.entries(clients)) { | ||
it("should have a service id matching its class name", () => { | ||
const index = parseInt(i); | ||
|
||
expect(client.config.serviceId).toEqual(serviceIds[index]); | ||
expect(client.constructor.name.replace(/Client$/, "")).toEqual(serviceIds[index]); | ||
}); | ||
} | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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 { requireRequestsFrom } from "@aws-sdk/aws-util-test/src"; | ||
import { | ||
type DescribeClusterCommandInput, | ||
Route53RecoveryControlConfig, | ||
waitUntilClusterCreated, | ||
} from "@aws-sdk/client-route53-recovery-control-config"; | ||
import { type HeadObjectCommandInput, S3, waitUntilObjectExists } from "@aws-sdk/client-s3"; | ||
import { HttpResponse } from "@smithy/protocol-http"; | ||
import { Readable } from "node:stream"; | ||
import { describe, test as it } from "vitest"; | ||
|
||
describe("waiters", () => { | ||
it("should poll until a return condition is met (http status)", async () => { | ||
const s3 = new S3({ | ||
credentials: { | ||
accessKeyId: "INTEG_TEST", | ||
secretAccessKey: "INTEG_TEST", | ||
}, | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(s3) | ||
.toMatch( | ||
{ | ||
hostname: /s3\.us-west-2\.amazonaws\.com/, | ||
}, | ||
{ | ||
hostname: /s3\.us-west-2\.amazonaws\.com/, | ||
} | ||
) | ||
.respondWith( | ||
new HttpResponse({ | ||
statusCode: 404, | ||
headers: {}, | ||
}), | ||
new HttpResponse({ | ||
statusCode: 200, | ||
headers: {}, | ||
}) | ||
); | ||
|
||
const waiterParams: HeadObjectCommandInput = { | ||
Bucket: "@@@@", | ||
Key: "####", | ||
}; | ||
|
||
await waitUntilObjectExists({ client: s3, maxDelay: 5, maxWaitTime: 20 }, waiterParams); | ||
}); | ||
|
||
it("should poll until a return condition is met (nested property)", async () => { | ||
const r53 = new Route53RecoveryControlConfig({ | ||
credentials: { | ||
accessKeyId: "INTEG_TEST", | ||
secretAccessKey: "INTEG_TEST", | ||
}, | ||
region: "us-west-2", | ||
}); | ||
|
||
requireRequestsFrom(r53) | ||
.toMatch( | ||
{ | ||
hostname: /amazon/, | ||
}, | ||
{ | ||
hostname: /amazon/, | ||
} | ||
) | ||
.respondWith( | ||
new HttpResponse({ | ||
statusCode: 200, | ||
headers: {}, | ||
body: Readable.from( | ||
JSON.stringify({ | ||
Cluster: { | ||
Status: "PENDING", | ||
}, | ||
}) | ||
), | ||
}), | ||
new HttpResponse({ | ||
statusCode: 200, | ||
headers: {}, | ||
body: Readable.from( | ||
JSON.stringify({ | ||
Cluster: { | ||
Status: "DEPLOYED", | ||
}, | ||
}) | ||
), | ||
}) | ||
); | ||
|
||
const waiterParams: DescribeClusterCommandInput = { | ||
ClusterArn: "@@@@", | ||
}; | ||
|
||
await waitUntilClusterCreated({ client: r53, maxDelay: 5, maxWaitTime: 20 }, waiterParams); | ||
}); | ||
}, 60_000); |
This file contains hidden or 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 hidden or 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 hidden or 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,33 @@ | ||
import { Sha256 } from "@aws-crypto/sha256-js"; | ||
import { describe, expect, test as it } from "vitest"; | ||
|
||
import { DsqlSigner, DsqlSignerConfig } from "./Signer"; | ||
|
||
describe("dsql-signer integration", () => { | ||
it("creates a token", async () => { | ||
const allParamsConfig: DsqlSignerConfig = { | ||
hostname: "localhost", | ||
region: "us-east-2", | ||
credentials: { | ||
accessKeyId: "allParamsAccessKey", | ||
secretAccessKey: "allParamsSecretAccessKey", | ||
sessionToken: "allParamsSessionToken", | ||
}, | ||
expiresIn: 1000, | ||
sha256: Sha256, | ||
}; | ||
const signer = new DsqlSigner(allParamsConfig); | ||
const token = await signer.getDbConnectAdminAuthToken(); | ||
|
||
expect(token.split("&").sort()).toMatchObject([ | ||
/localhost\/\?Action=DbConnectAdmin/, | ||
/X-Amz-Algorithm=AWS4-HMAC-SHA256/, | ||
/X-Amz-Credential=allParamsAccessKey%2F(\d+)%2Fus-east-2%2Fdsql%2Faws4_request/, | ||
/X-Amz-Date=(\d+T\d+Z)/, | ||
/X-Amz-Expires=1000/, | ||
/X-Amz-Security-Token=allParamsSessionToken/, | ||
/X-Amz-Signature=(.*?)/, | ||
/X-Amz-SignedHeaders=host/, | ||
]); | ||
}); | ||
}); |
This file contains hidden or 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,8 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ["**/*.integ.spec.ts"], | ||
environment: "node", | ||
}, | ||
}); |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.