@@ -461,6 +461,59 @@ mocha.describe('s3_ops', function() {
461
461
} ) ;
462
462
} ) ;
463
463
464
+ mocha . describe ( 'bucket-cors' , function ( ) {
465
+
466
+ mocha . before ( async function ( ) {
467
+ await s3 . createBucket ( { Bucket : "cors-bucket" } ) ;
468
+ } ) ;
469
+
470
+ mocha . it ( 'should put and get bucket cors with ID' , async function ( ) {
471
+
472
+ // put bucket cors
473
+ const params = {
474
+ Bucket : "cors-bucket" ,
475
+ CORSConfiguration : {
476
+ CORSRules : [ {
477
+ ID : 'rule1' ,
478
+ AllowedOrigins : [ "http://www.example.com" ] ,
479
+ AllowedHeaders : [ "*" ] ,
480
+ AllowedMethods : [ "PUT" , "POST" , "DELETE" ] ,
481
+ ExposeHeaders : [ "x-amz-server-side-encryption" ]
482
+ } ]
483
+ }
484
+ } ;
485
+ await s3 . putBucketCors ( params ) ;
486
+
487
+ // get bucket CORS
488
+ const res = await s3 . getBucketCors ( { Bucket : "cors-bucket" } ) ;
489
+ assert . deepEqual ( res . CORSRules , params . CORSConfiguration . CORSRules ) ;
490
+ } ) ;
491
+
492
+ mocha . it ( 'should put and get bucket cors with max age seconds' , async function ( ) {
493
+
494
+ // put bucket cors
495
+ const params = {
496
+ Bucket : "cors-bucket" ,
497
+ CORSConfiguration : {
498
+ CORSRules : [ {
499
+ AllowedOrigins : [ "http://www.example.com" ] ,
500
+ AllowedMethods : [ "PUT" , "POST" , "DELETE" ] ,
501
+ MaxAgeSeconds : 1500 ,
502
+ } ]
503
+ }
504
+ } ;
505
+ await s3 . putBucketCors ( params ) ;
506
+
507
+ // get bucket CORS
508
+ const res = await s3 . getBucketCors ( { Bucket : "cors-bucket" } ) ;
509
+ assert . deepEqual ( res . CORSRules , params . CORSConfiguration . CORSRules ) ;
510
+ } ) ;
511
+
512
+ mocha . after ( async function ( ) {
513
+ await s3 . deleteBucket ( { Bucket : "cors-bucket" } ) ;
514
+ } ) ;
515
+ } ) ;
516
+
464
517
async function test_object_ops ( bucket_name , bucket_type , caching , remote_endpoint_options ) {
465
518
466
519
const is_azure_namespace = is_namespace_blob_bucket ( bucket_type , remote_endpoint_options && remote_endpoint_options . endpoint_type ) ;
0 commit comments