@@ -247,6 +247,7 @@ def test_storage_transfer_service_client_client_options(
247247 quota_project_id = None ,
248248 client_info = transports .base .DEFAULT_CLIENT_INFO ,
249249 always_use_jwt_access = True ,
250+  api_audience = None ,
250251 )
251252
252253 # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is 
@@ -264,6 +265,7 @@ def test_storage_transfer_service_client_client_options(
264265 quota_project_id = None ,
265266 client_info = transports .base .DEFAULT_CLIENT_INFO ,
266267 always_use_jwt_access = True ,
268+  api_audience = None ,
267269 )
268270
269271 # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is 
@@ -281,6 +283,7 @@ def test_storage_transfer_service_client_client_options(
281283 quota_project_id = None ,
282284 client_info = transports .base .DEFAULT_CLIENT_INFO ,
283285 always_use_jwt_access = True ,
286+  api_audience = None ,
284287 )
285288
286289 # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has 
@@ -310,6 +313,25 @@ def test_storage_transfer_service_client_client_options(
310313 quota_project_id = "octopus" ,
311314 client_info = transports .base .DEFAULT_CLIENT_INFO ,
312315 always_use_jwt_access = True ,
316+  api_audience = None ,
317+  )
318+  # Check the case api_endpoint is provided 
319+  options  =  client_options .ClientOptions (
320+  api_audience = "https://language.googleapis.com" 
321+  )
322+  with  mock .patch .object (transport_class , "__init__" ) as  patched :
323+  patched .return_value  =  None 
324+  client  =  client_class (client_options = options , transport = transport_name )
325+  patched .assert_called_once_with (
326+  credentials = None ,
327+  credentials_file = None ,
328+  host = client .DEFAULT_ENDPOINT ,
329+  scopes = None ,
330+  client_cert_source_for_mtls = None ,
331+  quota_project_id = None ,
332+  client_info = transports .base .DEFAULT_CLIENT_INFO ,
333+  always_use_jwt_access = True ,
334+  api_audience = "https://language.googleapis.com" ,
313335 )
314336
315337
@@ -387,6 +409,7 @@ def test_storage_transfer_service_client_mtls_env_auto(
387409 quota_project_id = None ,
388410 client_info = transports .base .DEFAULT_CLIENT_INFO ,
389411 always_use_jwt_access = True ,
412+  api_audience = None ,
390413 )
391414
392415 # Check the case ADC client cert is provided. Whether client cert is used depends on 
@@ -421,6 +444,7 @@ def test_storage_transfer_service_client_mtls_env_auto(
421444 quota_project_id = None ,
422445 client_info = transports .base .DEFAULT_CLIENT_INFO ,
423446 always_use_jwt_access = True ,
447+  api_audience = None ,
424448 )
425449
426450 # Check the case client_cert_source and ADC client cert are not provided. 
@@ -443,6 +467,7 @@ def test_storage_transfer_service_client_mtls_env_auto(
443467 quota_project_id = None ,
444468 client_info = transports .base .DEFAULT_CLIENT_INFO ,
445469 always_use_jwt_access = True ,
470+  api_audience = None ,
446471 )
447472
448473
@@ -563,6 +588,7 @@ def test_storage_transfer_service_client_client_options_scopes(
563588 quota_project_id = None ,
564589 client_info = transports .base .DEFAULT_CLIENT_INFO ,
565590 always_use_jwt_access = True ,
591+  api_audience = None ,
566592 )
567593
568594
@@ -601,6 +627,7 @@ def test_storage_transfer_service_client_client_options_credentials_file(
601627 quota_project_id = None ,
602628 client_info = transports .base .DEFAULT_CLIENT_INFO ,
603629 always_use_jwt_access = True ,
630+  api_audience = None ,
604631 )
605632
606633
@@ -621,6 +648,7 @@ def test_storage_transfer_service_client_client_options_from_dict():
621648 quota_project_id = None ,
622649 client_info = transports .base .DEFAULT_CLIENT_INFO ,
623650 always_use_jwt_access = True ,
651+  api_audience = None ,
624652 )
625653
626654
@@ -659,6 +687,7 @@ def test_storage_transfer_service_client_create_channel_credentials_file(
659687 quota_project_id = None ,
660688 client_info = transports .base .DEFAULT_CLIENT_INFO ,
661689 always_use_jwt_access = True ,
690+  api_audience = None ,
662691 )
663692
664693 # test that the credentials from file are saved and used as the credentials. 
@@ -3709,6 +3738,28 @@ def test_storage_transfer_service_transport_auth_adc(transport_class):
37093738 )
37103739
37113740
3741+ @pytest .mark .parametrize ( 
3742+  "transport_class" , 
3743+  [ 
3744+  transports .StorageTransferServiceGrpcTransport , 
3745+  transports .StorageTransferServiceGrpcAsyncIOTransport , 
3746+  ], 
3747+ ) 
3748+ def  test_storage_transfer_service_transport_auth_gdch_credentials (transport_class ):
3749+  host  =  "https://language.com" 
3750+  api_audience_tests  =  [None , "https://language2.com" ]
3751+  api_audience_expect  =  [host , "https://language2.com" ]
3752+  for  t , e  in  zip (api_audience_tests , api_audience_expect ):
3753+  with  mock .patch .object (google .auth , "default" , autospec = True ) as  adc :
3754+  gdch_mock  =  mock .MagicMock ()
3755+  type(gdch_mock ).with_gdch_audience  =  mock .PropertyMock (
3756+  return_value = gdch_mock 
3757+  )
3758+  adc .return_value  =  (gdch_mock , None )
3759+  transport_class (host = host , api_audience = t )
3760+  gdch_mock .with_gdch_audience .assert_called_once_with (e )
3761+ 
3762+ 
37123763@pytest .mark .parametrize ( 
37133764 "transport_class,grpc_helpers" , 
37143765 [ 
@@ -4215,4 +4266,5 @@ def test_api_key_credentials(client_class, transport_class):
42154266 quota_project_id = None ,
42164267 client_info = transports .base .DEFAULT_CLIENT_INFO ,
42174268 always_use_jwt_access = True ,
4269+  api_audience = None ,
42184270 )
0 commit comments