@@ -2551,14 +2551,17 @@ describe('storage', () => {
2551
2551
before ( async ( ) => {
2552
2552
bucket = storage . bucket ( generateName ( ) , { kmsKeyName} ) ;
2553
2553
await bucket . create ( ) ;
2554
+ } ) ;
2555
+
2556
+ beforeEach ( async ( ) => {
2554
2557
await bucket . setMetadata ( {
2555
2558
encryption : {
2556
2559
defaultKmsKeyName : kmsKeyName ,
2557
2560
} ,
2558
2561
} ) ;
2559
2562
} ) ;
2560
2563
2561
- after ( async ( ) => {
2564
+ afterEach ( async ( ) => {
2562
2565
await bucket . setMetadata ( {
2563
2566
encryption : null ,
2564
2567
} ) ;
@@ -2590,24 +2593,13 @@ describe('storage', () => {
2590
2593
it ( 'should insert an object that inherits the kms key name' , async ( ) => {
2591
2594
const file = bucket . file ( 'kms-encrypted-file' ) ;
2592
2595
const [ metadata ] = await bucket . getMetadata ( ) ;
2593
- const defaultKmsKeyName = metadata . encryption . defaultKmsKeyName ;
2594
2596
await file . save ( FILE_CONTENTS , { resumable : false } ) ;
2597
+ const [ fileMetadata ] = await file . getMetadata ( ) ;
2595
2598
2596
- // Strip the project ID, as it could be the placeholder locally,
2597
- // but the real value upstream.
2598
- const projectIdRegExp = / ^ .+ \/ l o c a t i o n s / ;
2599
- const actualKmsKeyName = file . metadata . kmsKeyName . replace (
2600
- projectIdRegExp ,
2601
- ''
2602
- ) ;
2603
- let expectedKmsKeyName = defaultKmsKeyName . replace (
2604
- projectIdRegExp ,
2605
- ''
2599
+ assert . strictEqual (
2600
+ fileMetadata . kmsKeyName ,
2601
+ `${ metadata . encryption . defaultKmsKeyName } /cryptoKeyVersions/1`
2606
2602
) ;
2607
-
2608
- // Upstream attaches a version.
2609
- expectedKmsKeyName = `${ expectedKmsKeyName } /cryptoKeyVersions/1` ;
2610
- assert . strictEqual ( actualKmsKeyName , expectedKmsKeyName ) ;
2611
2603
} ) ;
2612
2604
} ) ;
2613
2605
} ) ;
0 commit comments