|
42 | 42 | )
|
43 | 43 | from google.cloud.functions_v1.services.cloud_functions_service import pagers
|
44 | 44 | from google.cloud.functions_v1.services.cloud_functions_service import transports
|
45 |
| -from google.cloud.functions_v1.services.cloud_functions_service.transports.base import ( |
46 |
| - _API_CORE_VERSION, |
47 |
| -) |
48 | 45 | from google.cloud.functions_v1.services.cloud_functions_service.transports.base import (
|
49 | 46 | _GOOGLE_AUTH_VERSION,
|
50 | 47 | )
|
|
62 | 59 | import google.auth
|
63 | 60 |
|
64 | 61 |
|
65 |
| -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
66 |
| -# - Delete all the api-core and auth "less than" test cases |
| 62 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 63 | +# through google-api-core: |
| 64 | +# - Delete the auth "less than" test cases |
67 | 65 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default).
|
68 | 66 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
|
69 | 67 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
|
|
74 | 72 | reason="This test requires google-auth >= 1.25.0",
|
75 | 73 | )
|
76 | 74 |
|
77 |
| -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
78 |
| - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
79 |
| - reason="This test requires google-api-core < 1.26.0", |
80 |
| -) |
81 |
| - |
82 |
| -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
83 |
| - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
84 |
| - reason="This test requires google-api-core >= 1.26.0", |
85 |
| -) |
86 |
| - |
87 | 75 |
|
88 | 76 | def client_cert_source_callback():
|
89 | 77 | return b"cert bytes", b"key bytes"
|
@@ -147,6 +135,18 @@ def test_cloud_functions_service_client_from_service_account_info(client_class):
|
147 | 135 | assert client.transport._host == "cloudfunctions.googleapis.com:443"
|
148 | 136 |
|
149 | 137 |
|
| 138 | +@pytest.mark.parametrize( |
| 139 | + "client_class", [CloudFunctionsServiceClient, CloudFunctionsServiceAsyncClient,] |
| 140 | +) |
| 141 | +def test_cloud_functions_service_client_service_account_always_use_jwt(client_class): |
| 142 | + with mock.patch.object( |
| 143 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 144 | + ) as use_jwt: |
| 145 | + creds = service_account.Credentials(None, None, None) |
| 146 | + client = client_class(credentials=creds) |
| 147 | + use_jwt.assert_called_with(True) |
| 148 | + |
| 149 | + |
150 | 150 | @pytest.mark.parametrize(
|
151 | 151 | "client_class", [CloudFunctionsServiceClient, CloudFunctionsServiceAsyncClient,]
|
152 | 152 | )
|
@@ -2955,7 +2955,6 @@ def test_cloud_functions_service_transport_auth_adc_old_google_auth(transport_cl
|
2955 | 2955 | (transports.CloudFunctionsServiceGrpcAsyncIOTransport, grpc_helpers_async),
|
2956 | 2956 | ],
|
2957 | 2957 | )
|
2958 |
| -@requires_api_core_gte_1_26_0 |
2959 | 2958 | def test_cloud_functions_service_transport_create_channel(
|
2960 | 2959 | transport_class, grpc_helpers
|
2961 | 2960 | ):
|
@@ -2986,79 +2985,6 @@ def test_cloud_functions_service_transport_create_channel(
|
2986 | 2985 | )
|
2987 | 2986 |
|
2988 | 2987 |
|
2989 |
| -@pytest.mark.parametrize( |
2990 |
| - "transport_class,grpc_helpers", |
2991 |
| - [ |
2992 |
| - (transports.CloudFunctionsServiceGrpcTransport, grpc_helpers), |
2993 |
| - (transports.CloudFunctionsServiceGrpcAsyncIOTransport, grpc_helpers_async), |
2994 |
| - ], |
2995 |
| -) |
2996 |
| -@requires_api_core_lt_1_26_0 |
2997 |
| -def test_cloud_functions_service_transport_create_channel_old_api_core( |
2998 |
| - transport_class, grpc_helpers |
2999 |
| -): |
3000 |
| - # If credentials and host are not provided, the transport class should use |
3001 |
| - # ADC credentials. |
3002 |
| - with mock.patch.object( |
3003 |
| - google.auth, "default", autospec=True |
3004 |
| - ) as adc, mock.patch.object( |
3005 |
| - grpc_helpers, "create_channel", autospec=True |
3006 |
| - ) as create_channel: |
3007 |
| - creds = ga_credentials.AnonymousCredentials() |
3008 |
| - adc.return_value = (creds, None) |
3009 |
| - transport_class(quota_project_id="octopus") |
3010 |
| - |
3011 |
| - create_channel.assert_called_with( |
3012 |
| - "cloudfunctions.googleapis.com:443", |
3013 |
| - credentials=creds, |
3014 |
| - credentials_file=None, |
3015 |
| - quota_project_id="octopus", |
3016 |
| - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
3017 |
| - ssl_credentials=None, |
3018 |
| - options=[ |
3019 |
| - ("grpc.max_send_message_length", -1), |
3020 |
| - ("grpc.max_receive_message_length", -1), |
3021 |
| - ], |
3022 |
| - ) |
3023 |
| - |
3024 |
| - |
3025 |
| -@pytest.mark.parametrize( |
3026 |
| - "transport_class,grpc_helpers", |
3027 |
| - [ |
3028 |
| - (transports.CloudFunctionsServiceGrpcTransport, grpc_helpers), |
3029 |
| - (transports.CloudFunctionsServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3030 |
| - ], |
3031 |
| -) |
3032 |
| -@requires_api_core_lt_1_26_0 |
3033 |
| -def test_cloud_functions_service_transport_create_channel_user_scopes( |
3034 |
| - transport_class, grpc_helpers |
3035 |
| -): |
3036 |
| - # If credentials and host are not provided, the transport class should use |
3037 |
| - # ADC credentials. |
3038 |
| - with mock.patch.object( |
3039 |
| - google.auth, "default", autospec=True |
3040 |
| - ) as adc, mock.patch.object( |
3041 |
| - grpc_helpers, "create_channel", autospec=True |
3042 |
| - ) as create_channel: |
3043 |
| - creds = ga_credentials.AnonymousCredentials() |
3044 |
| - adc.return_value = (creds, None) |
3045 |
| - |
3046 |
| - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
3047 |
| - |
3048 |
| - create_channel.assert_called_with( |
3049 |
| - "cloudfunctions.googleapis.com:443", |
3050 |
| - credentials=creds, |
3051 |
| - credentials_file=None, |
3052 |
| - quota_project_id="octopus", |
3053 |
| - scopes=["1", "2"], |
3054 |
| - ssl_credentials=None, |
3055 |
| - options=[ |
3056 |
| - ("grpc.max_send_message_length", -1), |
3057 |
| - ("grpc.max_receive_message_length", -1), |
3058 |
| - ], |
3059 |
| - ) |
3060 |
| - |
3061 |
| - |
3062 | 2988 | @pytest.mark.parametrize(
|
3063 | 2989 | "transport_class",
|
3064 | 2990 | [
|
|
0 commit comments