@@ -405,6 +405,7 @@ describe('POST /admin/catalog/visibility', () => {
405405 util . lambda . invoke = jest . fn ( ) . mockReturnValue ( promiser ( ) )
406406
407407 process . env . StaticBucketName = 'myBucket'
408+ process . env . SourceAccount = '123412341234'
408409
409410 await adminCatalogVisibility . post ( req , mockResponseObject )
410411
@@ -422,7 +423,8 @@ describe('POST /admin/catalog/visibility', () => {
422423 Key : 'catalog/a1b2c3_prod.json' ,
423424 Body : Buffer . from ( JSON . stringify ( {
424425 info : { title : 'swagger document' }
425- } ) )
426+ } ) ) ,
427+ ExpectedBucketOwner : '123412341234'
426428 } )
427429
428430 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
@@ -443,6 +445,7 @@ describe('POST /admin/catalog/visibility', () => {
443445 util . lambda . invoke = jest . fn ( ) . mockReturnValue ( promiser ( ) )
444446
445447 process . env . StaticBucketName = 'myBucket'
448+ process . env . SourceAccount = '123412341234'
446449
447450 await adminCatalogVisibility . post ( req , mockResponseObject )
448451
@@ -460,7 +463,8 @@ describe('POST /admin/catalog/visibility', () => {
460463 Key : 'catalog/unsubscribable_a1b2c3_prod.json' ,
461464 Body : Buffer . from ( JSON . stringify ( {
462465 info : { title : 'swagger document' }
463- } ) )
466+ } ) ) ,
467+ ExpectedBucketOwner : '123412341234'
464468 } )
465469
466470 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
@@ -475,13 +479,15 @@ describe('POST /admin/catalog/visibility', () => {
475479 util . lambda . invoke = jest . fn ( ) . mockReturnValue ( promiser ( ) )
476480
477481 process . env . StaticBucketName = 'myPail'
482+ process . env . SourceAccount = '123412341234'
478483
479484 await adminCatalogVisibility . post ( req , mockResponseObject )
480485
481486 expect ( util . s3 . upload ) . toHaveBeenCalledWith ( {
482487 Bucket : 'myPail' ,
483488 Key : `catalog/${ hash ( { info : { title : 'swagger document' } } ) } .json` ,
484- Body : Buffer . from ( JSON . stringify ( { info : { title : 'swagger document' } } ) )
489+ Body : Buffer . from ( JSON . stringify ( { info : { title : 'swagger document' } } ) ) ,
490+ ExpectedBucketOwner : '123412341234'
485491 } )
486492
487493 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
@@ -531,16 +537,19 @@ describe('DELETE /admin/catalog/visibility/:id', () => {
531537 util . s3 . deleteObject = jest . fn ( ) . mockReturnValue ( promiser ( ) )
532538
533539 process . env . StaticBucketName = 'myOtherBucket'
540+ process . env . SourceAccount = '123412341234'
534541
535542 await adminCatalogVisibility . delete ( req , mockResponseObject )
536543
537544 expect ( util . s3 . deleteObject ) . toHaveBeenCalledWith ( {
538545 Bucket : 'myOtherBucket' ,
539- Key : 'catalog/unsubscribable_a1b2c3_prod.json'
546+ Key : 'catalog/unsubscribable_a1b2c3_prod.json' ,
547+ ExpectedBucketOwner : '123412341234'
540548 } )
541549 expect ( util . s3 . deleteObject ) . toHaveBeenCalledWith ( {
542550 Bucket : 'myOtherBucket' ,
543- Key : 'catalog/a1b2c3_prod.json'
551+ Key : 'catalog/a1b2c3_prod.json' ,
552+ ExpectedBucketOwner : '123412341234'
544553 } )
545554
546555 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
@@ -554,16 +563,19 @@ describe('DELETE /admin/catalog/visibility/:id', () => {
554563 util . s3 . deleteObject = jest . fn ( ) . mockReturnValue ( promiser ( ) )
555564
556565 process . env . StaticBucketName = 'myOtherBucket'
566+ process . env . SourceAccount = '123412341234'
557567
558568 await adminCatalogVisibility . delete ( req , mockResponseObject )
559569
560570 expect ( util . s3 . deleteObject ) . toHaveBeenCalledWith ( {
561571 Bucket : 'myOtherBucket' ,
562- Key : 'catalog/unsubscribable_a1b2c3_unmatched.json'
572+ Key : 'catalog/unsubscribable_a1b2c3_unmatched.json' ,
573+ ExpectedBucketOwner : '123412341234'
563574 } )
564575 expect ( util . s3 . deleteObject ) . toHaveBeenCalledWith ( {
565576 Bucket : 'myOtherBucket' ,
566- Key : 'catalog/a1b2c3_unmatched.json'
577+ Key : 'catalog/a1b2c3_unmatched.json' ,
578+ ExpectedBucketOwner : '123412341234'
567579 } )
568580
569581 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
@@ -577,12 +589,14 @@ describe('DELETE /admin/catalog/visibility/:id', () => {
577589 util . s3 . deleteObject = jest . fn ( ) . mockReturnValue ( promiser ( ) )
578590
579591 process . env . StaticBucketName = 'anotherBucket'
592+ process . env . SourceAccount = '123412341234'
580593
581594 await adminCatalogVisibility . delete ( req , mockResponseObject )
582595
583596 expect ( util . s3 . deleteObject ) . toHaveBeenCalledWith ( {
584597 Bucket : 'anotherBucket' ,
585- Key : 'catalog/somebighash123456.json'
598+ Key : 'catalog/somebighash123456.json' ,
599+ ExpectedBucketOwner : '123412341234'
586600 } )
587601
588602 expect ( mockResponseObject . status ) . toHaveBeenCalledWith ( 200 )
0 commit comments