@@ -331,3 +331,56 @@ def keyring(storage_client, kms_bucket, kms_client):
331
331
except exceptions .NotFound :
332
332
key = {"purpose" : purpose }
333
333
kms_client .create_crypto_key (keyring_path , key_name , key )
334
+
335
+
336
+ @pytest .fixture (scope = "function" )
337
+ def test_universe_domain ():
338
+ if _helpers .test_universe_domain is None :
339
+ pytest .skip ("TEST_UNIVERSE_DOMAIN not set in environment." )
340
+ return _helpers .test_universe_domain
341
+
342
+
343
+ @pytest .fixture (scope = "function" )
344
+ def test_universe_project_id ():
345
+ if _helpers .test_universe_project_id is None :
346
+ pytest .skip ("TEST_UNIVERSE_PROJECT_ID not set in environment." )
347
+ return _helpers .test_universe_project_id
348
+
349
+
350
+ @pytest .fixture (scope = "function" )
351
+ def test_universe_location ():
352
+ if _helpers .test_universe_location is None :
353
+ pytest .skip ("TEST_UNIVERSE_LOCATION not set in environment." )
354
+ return _helpers .test_universe_location
355
+
356
+
357
+ @pytest .fixture (scope = "function" )
358
+ def test_universe_domain_credential ():
359
+ if _helpers .test_universe_domain_credential is None :
360
+ pytest .skip ("TEST_UNIVERSE_DOMAIN_CREDENTIAL not set in environment." )
361
+ return _helpers .test_universe_domain_credential
362
+
363
+
364
+ @pytest .fixture (scope = "function" )
365
+ def universe_domain_credential (test_universe_domain_credential ):
366
+ from google .oauth2 import service_account
367
+
368
+ return service_account .Credentials .from_service_account_file (
369
+ test_universe_domain_credential
370
+ )
371
+
372
+
373
+ @pytest .fixture (scope = "function" )
374
+ def universe_domain_client (
375
+ test_universe_domain , test_universe_project_id , universe_domain_credential
376
+ ):
377
+ from google .cloud .storage import Client
378
+
379
+ client_options = {"universe_domain" : test_universe_domain }
380
+ ud_storage_client = Client (
381
+ project = test_universe_project_id ,
382
+ credentials = universe_domain_credential ,
383
+ client_options = client_options ,
384
+ )
385
+ with contextlib .closing (ud_storage_client ):
386
+ yield ud_storage_client
0 commit comments