@@ -399,48 +399,80 @@ describe('prepareRequestContexts', () => {
399399
400400 describe ( 'objectGetAttributes' , ( ) => {
401401 describe ( 'x-amz-object-attributes header' , ( ) => {
402- it ( 'should request for specific permission if the header is set ' , ( ) => {
402+ it ( 'should include scality:GetObjectAttributes with x-amz-meta attribute ' , ( ) => {
403403 const apiMethod = 'objectGetAttributes' ;
404404 const request = makeRequest ( {
405405 'x-amz-object-attributes' : 'x-amz-meta-department' ,
406406 } ) ;
407407 const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
408408
409- assert . strictEqual ( results . length , 2 ) ;
410- assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
411- assert . strictEqual ( results [ 1 ] . getAction ( ) , 'scality:GetObjectAttributes' ) ;
409+ assert . strictEqual ( results . length , 3 ) ;
410+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObject' ) ;
411+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
412+ assert . strictEqual ( results [ 2 ] . getAction ( ) , 'scality:GetObjectAttributesCustom' ) ;
412413 } ) ;
413414
414- it ( 'should request for specific permission if the header is set with multiple value ' , ( ) => {
415+ it ( 'should include scality:GetObjectAttributes with multiple attributes ' , ( ) => {
415416 const apiMethod = 'objectGetAttributes' ;
416417 const request = makeRequest ( {
417418 'x-amz-object-attributes' : 'x-amz-meta-department,ETag' ,
418419 } ) ;
419420 const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
420421
421- assert . strictEqual ( results . length , 2 ) ;
422- assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
423- assert . strictEqual ( results [ 1 ] . getAction ( ) , 'scality:GetObjectAttributes' ) ;
422+ assert . strictEqual ( results . length , 3 ) ;
423+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObject' ) ;
424+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
425+ assert . strictEqual ( results [ 2 ] . getAction ( ) , 'scality:GetObjectAttributesCustom' ) ;
424426 } ) ;
425427
426- it ( 'should not request permission if the header contains only RestoreStatus' , ( ) => {
428+ it ( 'should not include scality:GetObjectAttributes with only RestoreStatus' , ( ) => {
427429 const apiMethod = 'objectGetAttributes' ;
428430 const request = makeRequest ( {
429431 'x-amz-object-attributes' : 'RestoreStatus' ,
430432 } ) ;
431433 const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
432434
433- assert . strictEqual ( results . length , 1 ) ;
434- assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
435+ assert . strictEqual ( results . length , 2 ) ;
436+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObject' ) ;
437+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
435438 } ) ;
436439
437- it ( 'should not request permission if the header does not exists ' , ( ) => {
440+ it ( 'should not include scality:GetObjectAttributes without header' , ( ) => {
438441 const apiMethod = 'objectGetAttributes' ;
439442 const request = makeRequest ( { } ) ;
440443 const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
441444
442- assert . strictEqual ( results . length , 1 ) ;
443- assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
445+ assert . strictEqual ( results . length , 2 ) ;
446+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObject' ) ;
447+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectAttributes' ) ;
448+ } ) ;
449+ } ) ;
450+
451+ describe ( 'x-amz-version-id header' , ( ) => {
452+ it ( 'should return version-specific actions with x-amz-version-id' , ( ) => {
453+ const apiMethod = 'objectGetAttributes' ;
454+ const request = makeRequest ( {
455+ 'x-amz-version-id' : '0987654323456789' ,
456+ } ) ;
457+ const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
458+
459+ assert . strictEqual ( results . length , 2 ) ;
460+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectVersion' ) ;
461+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectVersionAttributes' ) ;
462+ } ) ;
463+
464+ it ( 'should include scality:GetObjectAttributes with x-amz-version-id and x-amz-meta' , ( ) => {
465+ const apiMethod = 'objectGetAttributes' ;
466+ const request = makeRequest ( {
467+ 'x-amz-version-id' : '0987654323456789' ,
468+ 'x-amz-object-attributes' : 'x-amz-meta-department' ,
469+ } ) ;
470+ const results = prepareRequestContexts ( apiMethod , request , sourceBucket , sourceObject , sourceVersionId ) ;
471+
472+ assert . strictEqual ( results . length , 3 ) ;
473+ assert . strictEqual ( results [ 0 ] . getAction ( ) , 's3:GetObjectVersion' ) ;
474+ assert . strictEqual ( results [ 1 ] . getAction ( ) , 's3:GetObjectVersionAttributes' ) ;
475+ assert . strictEqual ( results [ 2 ] . getAction ( ) , 'scality:GetObjectAttributesCustom' ) ;
444476 } ) ;
445477 } ) ;
446478 } ) ;
0 commit comments