3333use Google \Cloud \SecretManager \V1 \CreateSecretRequest ;
3434use Google \Cloud \SecretManager \V1 \DeleteSecretRequest ;
3535use Google \Cloud \SecretManager \V1 \DisableSecretVersionRequest ;
36+ use Google \Cloud \SecretManager \V1 \GetSecretRequest ;
3637use Google \Cloud \SecretManager \V1 \Secret ;
3738use Google \Cloud \SecretManager \V1 \SecretPayload ;
3839use Google \Cloud \SecretManager \V1 \SecretVersion ;
@@ -166,6 +167,13 @@ private static function deleteSecret(string $name)
166167 }
167168 }
168169
170+ private static function getSecret (string $ projectId , string $ locationId , string $ secretId ): Secret
171+ {
172+ $ name = self ::$ client ->projectLocationSecretName ($ projectId , $ locationId , $ secretId );
173+ $ getSecretRequest = (new GetSecretRequest ())->setName ($ name );
174+ return self ::$ client ->getSecret ($ getSecretRequest );
175+ }
176+
169177 private static function createTagKey (string $ short_name ): string
170178 {
171179 $ parent = self ::$ client ->projectName (self ::$ projectId );
@@ -605,6 +613,9 @@ public function testCreateSecretWithDelayedDestroyed()
605613 ]);
606614
607615 $ this ->assertStringContainsString ('Created secret ' , $ output );
616+
617+ $ secret = self ::getSecret ($ name ['project ' ], $ name ['location ' ], $ name ['secret ' ]);
618+ $ this ->assertEquals (self ::$ testDelayedDestroyTime , $ secret ->getVersionDestroyTtl ()->getSeconds ());
608619 }
609620
610621 public function testDisableSecretDelayedDestroy ()
@@ -618,6 +629,9 @@ public function testDisableSecretDelayedDestroy()
618629 ]);
619630
620631 $ this ->assertStringContainsString ('Updated secret ' , $ output );
632+
633+ $ secret = self ::getSecret ($ name ['project ' ], $ name ['location ' ], $ name ['secret ' ]);
634+ $ this ->assertNull ($ secret ->getVersionDestroyTtl ());
621635 }
622636
623637 public function testUpdateSecretWithDelayedDestroyed ()
@@ -632,5 +646,7 @@ public function testUpdateSecretWithDelayedDestroyed()
632646 ]);
633647
634648 $ this ->assertStringContainsString ('Updated secret ' , $ output );
649+ $ secret = self ::getSecret ($ name ['project ' ], $ name ['location ' ], $ name ['secret ' ]);
650+ $ this ->assertEquals (self ::$ testDelayedDestroyTime , $ secret ->getVersionDestroyTtl ()->getSeconds ());
635651 }
636652}
0 commit comments