@@ -6,6 +6,11 @@ const withV4 = require('../support/withV4');
66const BucketUtility = require ( '../../lib/utility/bucket-util' ) ;
77const kms = require ( '../../../../../lib/kms/wrapper' ) ;
88const { DummyRequestLogger } = require ( '../../../../unit/helpers' ) ;
9+ const { config } = require ( '../../../../../lib/Config' ) ;
10+ const { getKeyIdFromArn } = require ( 'arsenal/build/lib/network/KMSInterface' ) ;
11+
12+ // For this test env S3_CONFIG_FILE should be the same as running cloudserver
13+ // to have the same config.kmsHideScalityArn value
914
1015const log = new DummyRequestLogger ( ) ;
1116
@@ -55,7 +60,9 @@ function createExpected(sseConfig, kmsKeyId) {
5560 }
5661
5762 if ( sseConfig . masterKeyId ) {
58- expected . masterKeyId = kmsKeyId ;
63+ expected . masterKeyId = config . kmsHideScalityArn
64+ ? getKeyIdFromArn ( kmsKeyId )
65+ : kmsKeyId ;
5966 }
6067 return expected ;
6168}
@@ -91,7 +98,7 @@ describe('per object encryption headers', () => {
9198 const bucket = new BucketInfo ( 'enc-bucket-test' , 'OwnerId' ,
9299 'OwnerDisplayName' , new Date ( ) . toJSON ( ) ) ;
93100 kms . createBucketKey ( bucket , log ,
94- ( err , { masterKeyId : keyId } ) => {
101+ ( err , { masterKeyArn : keyId } ) => {
95102 assert . ifError ( err ) ;
96103 kmsKeyId = keyId ;
97104 done ( ) ;
@@ -221,7 +228,9 @@ describe('per object encryption headers', () => {
221228 done => {
222229 const _existing = Object . assign ( { } , existing ) ;
223230 if ( existing . masterKeyId ) {
224- _existing . masterKeyId = kmsKeyId ;
231+ _existing . masterKeyId = config . kmsHideScalityArn
232+ ? getKeyIdFromArn ( kmsKeyId )
233+ : kmsKeyId ;
225234 }
226235 const params = {
227236 Bucket : bucket2 ,
0 commit comments