-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(middleware-sdk-s3): add e2e test for throw-200-errors (#6360)
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/middleware-sdk-s3/src/throw-200-exceptions.e2e.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,57 @@ | ||
import { S3 } from "@aws-sdk/client-s3"; | ||
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts"; | ||
|
||
jest.setTimeout(100000); | ||
|
||
describe("S3 throw 200 exceptions", () => { | ||
const config = { | ||
region: "us-west-2", | ||
}; | ||
const s3 = new S3(config); | ||
const stsClient = new STS(config); | ||
|
||
const alphabet = "abcdefghijklmnopqrstuvwxyz"; | ||
const randId = alphabet[(Math.random() * alphabet.length) | 0] + alphabet[(Math.random() * alphabet.length) | 0]; | ||
let Bucket: string; | ||
let callerID: GetCallerIdentityCommandOutput; | ||
|
||
beforeAll(async () => { | ||
callerID = await stsClient.getCallerIdentity({}); | ||
Bucket = `${callerID.Account}-${randId}-s3-200s-e2e-test-empty-${config.region}-${(Date.now() / 1000) | 0}`; | ||
|
||
await s3.createBucket({ | ||
Bucket, | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
const list = await s3.listObjectsV2({ | ||
Bucket, | ||
}); | ||
for (const item of list.Contents ?? []) { | ||
await s3.deleteObject({ | ||
Bucket, | ||
Key: item.Key, | ||
}); | ||
} | ||
|
||
await s3.deleteBucket({ | ||
Bucket, | ||
}); | ||
s3.destroy(); | ||
}); | ||
|
||
it("should split stream successfully for less than 3kb payload and greater than 3kb payload", async () => { | ||
for (let i = 0; i < 10; ++i) { | ||
await s3.listObjects({ | ||
Bucket, | ||
}); | ||
|
||
await s3.putObject({ | ||
Bucket, | ||
Key: i + "long-text-".repeat(10), | ||
Body: "abcd", | ||
}); | ||
} | ||
}); | ||
}); |