15
15
16
16
import time
17
17
from os import environ
18
+ import uuid
18
19
19
20
from google .api_core .exceptions import Aborted , GoogleAPICallError
20
21
from google .cloud import kms_v1
@@ -63,7 +64,7 @@ def setup_module(module):
63
64
64
65
class TestKMSSnippets :
65
66
project_id = environ ['GCLOUD_PROJECT' ]
66
- keyring_id = 'kms-samples'
67
+ keyring_id = 'kms-samples-{}' . format ( uuid . uuid4 (). hex )
67
68
location = 'global'
68
69
parent = 'projects/{}/locations/{}' .format (project_id , location )
69
70
keyring_path = '{}/keyRings/{}' .format (parent , keyring_id )
@@ -83,7 +84,7 @@ class TestKMSSnippets:
83
84
@pytest .mark .skip (reason = "There's currently no method to delete keyrings, \
84
85
so we should avoid creating resources" )
85
86
def test_create_key_ring (self ):
86
- ring_id = self .keyring_id + '-testcreate' + str ( int ( time . time ()) )
87
+ ring_id = self .keyring_id + '-test-create-{}' . format ( uuid . uuid4 (). hex )
87
88
snippets .create_key_ring (self .project_id , self .location , ring_id )
88
89
client = kms_v1 .KeyManagementServiceClient ()
89
90
result = client .get_key_ring (client .key_ring_path (self .project_id ,
@@ -94,7 +95,7 @@ def test_create_key_ring(self):
94
95
@pytest .mark .skip (reason = "Deleting keys isn't instant, so we should avoid \
95
96
creating a large number of them in our tests" )
96
97
def test_create_crypto_key (self ):
97
- key_id = self .sym_id + '-test' + str ( int ( time . time ()) )
98
+ key_id = self .sym_id + '-test-{}' . format ( uuid . uuid4 (). hex )
98
99
snippets .create_crypto_key (self .project_id , self .location ,
99
100
self .keyring_id , key_id )
100
101
c = kms_v1 .KeyManagementServiceClient ()
0 commit comments