File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
packages/middleware-sdk-s3/src Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ import { S3 } from "@aws-sdk/client-s3" ;
2+ import { GetCallerIdentityCommandOutput , STS } from "@aws-sdk/client-sts" ;
3+
4+ jest . setTimeout ( 100000 ) ;
5+
6+ describe ( "S3 throw 200 exceptions" , ( ) => {
7+ const config = {
8+ region : "us-west-2" ,
9+ } ;
10+ const s3 = new S3 ( config ) ;
11+ const stsClient = new STS ( config ) ;
12+
13+ const alphabet = "abcdefghijklmnopqrstuvwxyz" ;
14+ const randId = alphabet [ ( Math . random ( ) * alphabet . length ) | 0 ] + alphabet [ ( Math . random ( ) * alphabet . length ) | 0 ] ;
15+ let Bucket : string ;
16+ let callerID : GetCallerIdentityCommandOutput ;
17+
18+ beforeAll ( async ( ) => {
19+ callerID = await stsClient . getCallerIdentity ( { } ) ;
20+ Bucket = `${ callerID . Account } -${ randId } -s3-200s-e2e-test-empty-${ config . region } -${ ( Date . now ( ) / 1000 ) | 0 } ` ;
21+
22+ await s3 . createBucket ( {
23+ Bucket,
24+ } ) ;
25+ } ) ;
26+
27+ afterAll ( async ( ) => {
28+ const list = await s3 . listObjectsV2 ( {
29+ Bucket,
30+ } ) ;
31+ for ( const item of list . Contents ?? [ ] ) {
32+ await s3 . deleteObject ( {
33+ Bucket,
34+ Key : item . Key ,
35+ } ) ;
36+ }
37+
38+ await s3 . deleteBucket ( {
39+ Bucket,
40+ } ) ;
41+ s3 . destroy ( ) ;
42+ } ) ;
43+
44+ it ( "should split stream successfully for less than 3kb payload and greater than 3kb payload" , async ( ) => {
45+ for ( let i = 0 ; i < 10 ; ++ i ) {
46+ await s3 . listObjects ( {
47+ Bucket,
48+ } ) ;
49+
50+ await s3 . putObject ( {
51+ Bucket,
52+ Key : i + "long-text-" . repeat ( 10 ) ,
53+ Body : "abcd" ,
54+ } ) ;
55+ }
56+ } ) ;
57+ } ) ;
You can’t perform that action at this time.
0 commit comments