@@ -232,6 +232,7 @@ def test_transcoder_service_client_client_options(
|
232 | 232 | quota_project_id=None,
|
233 | 233 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
234 | 234 | always_use_jwt_access=True,
|
| 235 | +api_audience=None, |
235 | 236 | )
|
236 | 237 |
|
237 | 238 | # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
|
@@ -249,6 +250,7 @@ def test_transcoder_service_client_client_options(
|
249 | 250 | quota_project_id=None,
|
250 | 251 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
251 | 252 | always_use_jwt_access=True,
|
| 253 | +api_audience=None, |
252 | 254 | )
|
253 | 255 |
|
254 | 256 | # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
|
@@ -266,6 +268,7 @@ def test_transcoder_service_client_client_options(
|
266 | 268 | quota_project_id=None,
|
267 | 269 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
268 | 270 | always_use_jwt_access=True,
|
| 271 | +api_audience=None, |
269 | 272 | )
|
270 | 273 |
|
271 | 274 | # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
|
@@ -295,6 +298,25 @@ def test_transcoder_service_client_client_options(
|
295 | 298 | quota_project_id="octopus",
|
296 | 299 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
297 | 300 | always_use_jwt_access=True,
|
| 301 | +api_audience=None, |
| 302 | +) |
| 303 | +# Check the case api_endpoint is provided |
| 304 | +options = client_options.ClientOptions( |
| 305 | +api_audience="https://language.googleapis.com" |
| 306 | +) |
| 307 | +with mock..object(transport_class, "__init__") as ed: |
| 308 | +ed.return_value = None |
| 309 | +client = client_class(client_options=options, transport=transport_name) |
| 310 | +ed.assert_called_once_with( |
| 311 | +credentials=None, |
| 312 | +credentials_file=None, |
| 313 | +host=client.DEFAULT_ENDPOINT, |
| 314 | +scopes=None, |
| 315 | +client_cert_source_for_mtls=None, |
| 316 | +quota_project_id=None, |
| 317 | +client_info=transports.base.DEFAULT_CLIENT_INFO, |
| 318 | +always_use_jwt_access=True, |
| 319 | +api_audience="https://language.googleapis.com", |
298 | 320 | )
|
299 | 321 |
|
300 | 322 |
|
@@ -372,6 +394,7 @@ def test_transcoder_service_client_mtls_env_auto(
|
372 | 394 | quota_project_id=None,
|
373 | 395 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
374 | 396 | always_use_jwt_access=True,
|
| 397 | +api_audience=None, |
375 | 398 | )
|
376 | 399 |
|
377 | 400 | # Check the case ADC client cert is provided. Whether client cert is used depends on
|
@@ -406,6 +429,7 @@ def test_transcoder_service_client_mtls_env_auto(
|
406 | 429 | quota_project_id=None,
|
407 | 430 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
408 | 431 | always_use_jwt_access=True,
|
| 432 | +api_audience=None, |
409 | 433 | )
|
410 | 434 |
|
411 | 435 | # Check the case client_cert_source and ADC client cert are not provided.
|
@@ -428,6 +452,7 @@ def test_transcoder_service_client_mtls_env_auto(
|
428 | 452 | quota_project_id=None,
|
429 | 453 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
430 | 454 | always_use_jwt_access=True,
|
| 455 | +api_audience=None, |
431 | 456 | )
|
432 | 457 |
|
433 | 458 |
|
@@ -542,6 +567,7 @@ def test_transcoder_service_client_client_options_scopes(
|
542 | 567 | quota_project_id=None,
|
543 | 568 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
544 | 569 | always_use_jwt_access=True,
|
| 570 | +api_audience=None, |
545 | 571 | )
|
546 | 572 |
|
547 | 573 |
|
@@ -580,6 +606,7 @@ def test_transcoder_service_client_client_options_credentials_file(
|
580 | 606 | quota_project_id=None,
|
581 | 607 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
582 | 608 | always_use_jwt_access=True,
|
| 609 | +api_audience=None, |
583 | 610 | )
|
584 | 611 |
|
585 | 612 |
|
@@ -600,6 +627,7 @@ def test_transcoder_service_client_client_options_from_dict():
|
600 | 627 | quota_project_id=None,
|
601 | 628 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
602 | 629 | always_use_jwt_access=True,
|
| 630 | +api_audience=None, |
603 | 631 | )
|
604 | 632 |
|
605 | 633 |
|
@@ -638,6 +666,7 @@ def test_transcoder_service_client_create_channel_credentials_file(
|
638 | 666 | quota_project_id=None,
|
639 | 667 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
640 | 668 | always_use_jwt_access=True,
|
| 669 | +api_audience=None, |
641 | 670 | )
|
642 | 671 |
|
643 | 672 | # test that the credentials from file are saved and used as the credentials.
|
@@ -3217,6 +3246,28 @@ def test_transcoder_service_transport_auth_adc(transport_class):
|
3217 | 3246 | )
|
3218 | 3247 |
|
3219 | 3248 |
|
| 3249 | +@pytest.mark.parametrize( |
| 3250 | +"transport_class", |
| 3251 | +[ |
| 3252 | +transports.TranscoderServiceGrpcTransport, |
| 3253 | +transports.TranscoderServiceGrpcAsyncIOTransport, |
| 3254 | +], |
| 3255 | +) |
| 3256 | +def test_transcoder_service_transport_auth_gdch_credentials(transport_class): |
| 3257 | +host = "https://language.com" |
| 3258 | +api_audience_tests = [None, "https://language2.com"] |
| 3259 | +api_audience_expect = [host, "https://language2.com"] |
| 3260 | +for t, e in zip(api_audience_tests, api_audience_expect): |
| 3261 | +with mock..object(google.auth, "default", autospec=True) as adc: |
| 3262 | +gdch_mock = mock.MagicMock() |
| 3263 | +type(gdch_mock).with_gdch_audience = mock.PropertyMock( |
| 3264 | +return_value=gdch_mock |
| 3265 | +) |
| 3266 | +adc.return_value = (gdch_mock, None) |
| 3267 | +transport_class(host=host, api_audience=t) |
| 3268 | +gdch_mock.with_gdch_audience.assert_called_once_with(e) |
| 3269 | + |
| 3270 | + |
3220 | 3271 | @pytest.mark.parametrize(
|
3221 | 3272 | "transport_class,grpc_helpers",
|
3222 | 3273 | [
|
@@ -3716,4 +3767,5 @@ def test_api_key_credentials(client_class, transport_class):
|
3716 | 3767 | quota_project_id=None,
|
3717 | 3768 | client_info=transports.base.DEFAULT_CLIENT_INFO,
|
3718 | 3769 | always_use_jwt_access=True,
|
| 3770 | +api_audience=None, |
3719 | 3771 | )
|
0 commit comments