@@ -543,4 +543,60 @@ describe('Secret Manager samples', () => {
543543 ) ;
544544 assert . match ( output , new RegExp ( `Destroyed ${ regionalVersion . name } ` ) ) ;
545545 } ) ;
546+
547+ it ( 'creates a secret with delayed destroy enabled' , async ( ) => {
548+ const timeToLive = 24 * 60 * 60 ;
549+ const output = execSync (
550+ `node createSecretWithDelayedDestroy.js projects/${ projectId } ${ secretId } -2 ${ timeToLive } `
551+ ) ;
552+ assert . match ( output , new RegExp ( 'Created secret' ) ) ;
553+ } ) ;
554+
555+ it ( 'disables a secret delayed destroy' , async ( ) => {
556+ await client . createSecret ( {
557+ parent : `projects/${ projectId } ` ,
558+ secretId : `${ secretId } -delayedDestroy` ,
559+ secret : {
560+ replication : {
561+ automatic : { } ,
562+ } ,
563+ version_destroy_ttl : {
564+ seconds : 24 * 60 * 60 ,
565+ } ,
566+ } ,
567+ } ) ;
568+
569+ const output = execSync (
570+ `node disableSecretDelayedDestroy.js ${ secret . name } -delayedDestroy`
571+ ) ;
572+ assert . match ( output , new RegExp ( 'Disabled delayed destroy' ) ) ;
573+
574+ await client . deleteSecret ( {
575+ name : `${ secret . name } -delayedDestroy` ,
576+ } ) ;
577+ } ) ;
578+
579+ it ( 'updates a secret delayed destroy' , async ( ) => {
580+ const updatedTimeToLive = 24 * 60 * 60 * 2 ;
581+ await client . createSecret ( {
582+ parent : `projects/${ projectId } ` ,
583+ secretId : `${ secretId } -delayedDestroy` ,
584+ secret : {
585+ replication : {
586+ automatic : { } ,
587+ } ,
588+ version_destroy_ttl : {
589+ seconds : 24 * 60 * 60 ,
590+ } ,
591+ } ,
592+ } ) ;
593+
594+ const output = execSync (
595+ `node updateSecretWithDelayedDestroy.js ${ secret . name } -delayedDestroy ${ updatedTimeToLive } `
596+ ) ;
597+ assert . match ( output , new RegExp ( 'Updated secret' ) ) ;
598+ await client . deleteSecret ( {
599+ name : `${ secret . name } -delayedDestroy` ,
600+ } ) ;
601+ } ) ;
546602} ) ;
0 commit comments