|
42 | 42 | ) |
43 | 43 | from google.cloud.apigateway_v1.services.api_gateway_service import pagers |
44 | 44 | from google.cloud.apigateway_v1.services.api_gateway_service import transports |
45 | | -from google.cloud.apigateway_v1.services.api_gateway_service.transports.base import ( |
46 | | - _API_CORE_VERSION, |
47 | | -) |
48 | 45 | from google.cloud.apigateway_v1.services.api_gateway_service.transports.base import ( |
49 | 46 | _GOOGLE_AUTH_VERSION, |
50 | 47 | ) |
|
56 | 53 | import google.auth |
57 | 54 |
|
58 | 55 |
|
59 | | -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
60 | | -# - Delete all the api-core and auth "less than" test cases |
| 56 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 57 | +# through google-api-core: |
| 58 | +# - Delete the auth "less than" test cases |
61 | 59 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default). |
62 | 60 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif( |
63 | 61 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), |
|
68 | 66 | reason="This test requires google-auth >= 1.25.0", |
69 | 67 | ) |
70 | 68 |
|
71 | | -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
72 | | - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
73 | | - reason="This test requires google-api-core < 1.26.0", |
74 | | -) |
75 | | - |
76 | | -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
77 | | - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
78 | | - reason="This test requires google-api-core >= 1.26.0", |
79 | | -) |
80 | | - |
81 | 69 |
|
82 | 70 | def client_cert_source_callback(): |
83 | 71 | return b"cert bytes", b"key bytes" |
@@ -141,6 +129,18 @@ def test_api_gateway_service_client_from_service_account_info(client_class): |
141 | 129 | assert client.transport._host == "apigateway.googleapis.com:443" |
142 | 130 |
|
143 | 131 |
|
| 132 | +@pytest.mark.parametrize( |
| 133 | + "client_class", [ApiGatewayServiceClient, ApiGatewayServiceAsyncClient,] |
| 134 | +) |
| 135 | +def test_api_gateway_service_client_service_account_always_use_jwt(client_class): |
| 136 | + with mock.patch.object( |
| 137 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 138 | + ) as use_jwt: |
| 139 | + creds = service_account.Credentials(None, None, None) |
| 140 | + client = client_class(credentials=creds) |
| 141 | + use_jwt.assert_called_with(True) |
| 142 | + |
| 143 | + |
144 | 144 | @pytest.mark.parametrize( |
145 | 145 | "client_class", [ApiGatewayServiceClient, ApiGatewayServiceAsyncClient,] |
146 | 146 | ) |
@@ -4356,7 +4356,6 @@ def test_api_gateway_service_transport_auth_adc_old_google_auth(transport_class) |
4356 | 4356 | (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4357 | 4357 | ], |
4358 | 4358 | ) |
4359 | | -@requires_api_core_gte_1_26_0 |
4360 | 4359 | def test_api_gateway_service_transport_create_channel(transport_class, grpc_helpers): |
4361 | 4360 | # If credentials and host are not provided, the transport class should use |
4362 | 4361 | # ADC credentials. |
@@ -4385,79 +4384,6 @@ def test_api_gateway_service_transport_create_channel(transport_class, grpc_help |
4385 | 4384 | ) |
4386 | 4385 |
|
4387 | 4386 |
|
4388 | | -@pytest.mark.parametrize( |
4389 | | - "transport_class,grpc_helpers", |
4390 | | - [ |
4391 | | - (transports.ApiGatewayServiceGrpcTransport, grpc_helpers), |
4392 | | - (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4393 | | - ], |
4394 | | -) |
4395 | | -@requires_api_core_lt_1_26_0 |
4396 | | -def test_api_gateway_service_transport_create_channel_old_api_core( |
4397 | | - transport_class, grpc_helpers |
4398 | | -): |
4399 | | - # If credentials and host are not provided, the transport class should use |
4400 | | - # ADC credentials. |
4401 | | - with mock.patch.object( |
4402 | | - google.auth, "default", autospec=True |
4403 | | - ) as adc, mock.patch.object( |
4404 | | - grpc_helpers, "create_channel", autospec=True |
4405 | | - ) as create_channel: |
4406 | | - creds = ga_credentials.AnonymousCredentials() |
4407 | | - adc.return_value = (creds, None) |
4408 | | - transport_class(quota_project_id="octopus") |
4409 | | - |
4410 | | - create_channel.assert_called_with( |
4411 | | - "apigateway.googleapis.com:443", |
4412 | | - credentials=creds, |
4413 | | - credentials_file=None, |
4414 | | - quota_project_id="octopus", |
4415 | | - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
4416 | | - ssl_credentials=None, |
4417 | | - options=[ |
4418 | | - ("grpc.max_send_message_length", -1), |
4419 | | - ("grpc.max_receive_message_length", -1), |
4420 | | - ], |
4421 | | - ) |
4422 | | - |
4423 | | - |
4424 | | -@pytest.mark.parametrize( |
4425 | | - "transport_class,grpc_helpers", |
4426 | | - [ |
4427 | | - (transports.ApiGatewayServiceGrpcTransport, grpc_helpers), |
4428 | | - (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4429 | | - ], |
4430 | | -) |
4431 | | -@requires_api_core_lt_1_26_0 |
4432 | | -def test_api_gateway_service_transport_create_channel_user_scopes( |
4433 | | - transport_class, grpc_helpers |
4434 | | -): |
4435 | | - # If credentials and host are not provided, the transport class should use |
4436 | | - # ADC credentials. |
4437 | | - with mock.patch.object( |
4438 | | - google.auth, "default", autospec=True |
4439 | | - ) as adc, mock.patch.object( |
4440 | | - grpc_helpers, "create_channel", autospec=True |
4441 | | - ) as create_channel: |
4442 | | - creds = ga_credentials.AnonymousCredentials() |
4443 | | - adc.return_value = (creds, None) |
4444 | | - |
4445 | | - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
4446 | | - |
4447 | | - create_channel.assert_called_with( |
4448 | | - "apigateway.googleapis.com:443", |
4449 | | - credentials=creds, |
4450 | | - credentials_file=None, |
4451 | | - quota_project_id="octopus", |
4452 | | - scopes=["1", "2"], |
4453 | | - ssl_credentials=None, |
4454 | | - options=[ |
4455 | | - ("grpc.max_send_message_length", -1), |
4456 | | - ("grpc.max_receive_message_length", -1), |
4457 | | - ], |
4458 | | - ) |
4459 | | - |
4460 | | - |
4461 | 4387 | @pytest.mark.parametrize( |
4462 | 4388 | "transport_class", |
4463 | 4389 | [ |
|
0 commit comments