|
44 | 44 | from google.cloud.managedidentities_v1.services.managed_identities_service import (
|
45 | 45 | transports,
|
46 | 46 | )
|
47 |
| -from google.cloud.managedidentities_v1.services.managed_identities_service.transports.base import ( |
48 |
| - _API_CORE_VERSION, |
49 |
| -) |
50 | 47 | from google.cloud.managedidentities_v1.services.managed_identities_service.transports.base import (
|
51 | 48 | _GOOGLE_AUTH_VERSION,
|
52 | 49 | )
|
|
59 | 56 | import google.auth
|
60 | 57 |
|
61 | 58 |
|
62 |
| -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
63 |
| -# - Delete all the api-core and auth "less than" test cases |
| 59 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 60 | +# through google-api-core: |
| 61 | +# - Delete the auth "less than" test cases |
64 | 62 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default).
|
65 | 63 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
|
66 | 64 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
|
|
71 | 69 | reason="This test requires google-auth >= 1.25.0",
|
72 | 70 | )
|
73 | 71 |
|
74 |
| -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
75 |
| - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
76 |
| - reason="This test requires google-api-core < 1.26.0", |
77 |
| -) |
78 |
| - |
79 |
| -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
80 |
| - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
81 |
| - reason="This test requires google-api-core >= 1.26.0", |
82 |
| -) |
83 |
| - |
84 | 72 |
|
85 | 73 | def client_cert_source_callback():
|
86 | 74 | return b"cert bytes", b"key bytes"
|
@@ -145,6 +133,19 @@ def test_managed_identities_service_client_from_service_account_info(client_clas
|
145 | 133 | assert client.transport._host == "managedidentities.googleapis.com:443"
|
146 | 134 |
|
147 | 135 |
|
| 136 | +@pytest.mark.parametrize( |
| 137 | + "client_class", |
| 138 | + [ManagedIdentitiesServiceClient, ManagedIdentitiesServiceAsyncClient,], |
| 139 | +) |
| 140 | +def test_managed_identities_service_client_service_account_always_use_jwt(client_class): |
| 141 | + with mock.patch.object( |
| 142 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 143 | + ) as use_jwt: |
| 144 | + creds = service_account.Credentials(None, None, None) |
| 145 | + client = client_class(credentials=creds) |
| 146 | + use_jwt.assert_called_with(True) |
| 147 | + |
| 148 | + |
148 | 149 | @pytest.mark.parametrize(
|
149 | 150 | "client_class",
|
150 | 151 | [ManagedIdentitiesServiceClient, ManagedIdentitiesServiceAsyncClient,],
|
@@ -3155,7 +3156,6 @@ def test_managed_identities_service_transport_auth_adc_old_google_auth(transport
|
3155 | 3156 | (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async),
|
3156 | 3157 | ],
|
3157 | 3158 | )
|
3158 |
| -@requires_api_core_gte_1_26_0 |
3159 | 3159 | def test_managed_identities_service_transport_create_channel(
|
3160 | 3160 | transport_class, grpc_helpers
|
3161 | 3161 | ):
|
@@ -3186,79 +3186,6 @@ def test_managed_identities_service_transport_create_channel(
|
3186 | 3186 | )
|
3187 | 3187 |
|
3188 | 3188 |
|
3189 |
| -@pytest.mark.parametrize( |
3190 |
| - "transport_class,grpc_helpers", |
3191 |
| - [ |
3192 |
| - (transports.ManagedIdentitiesServiceGrpcTransport, grpc_helpers), |
3193 |
| - (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3194 |
| - ], |
3195 |
| -) |
3196 |
| -@requires_api_core_lt_1_26_0 |
3197 |
| -def test_managed_identities_service_transport_create_channel_old_api_core( |
3198 |
| - transport_class, grpc_helpers |
3199 |
| -): |
3200 |
| - # If credentials and host are not provided, the transport class should use |
3201 |
| - # ADC credentials. |
3202 |
| - with mock.patch.object( |
3203 |
| - google.auth, "default", autospec=True |
3204 |
| - ) as adc, mock.patch.object( |
3205 |
| - grpc_helpers, "create_channel", autospec=True |
3206 |
| - ) as create_channel: |
3207 |
| - creds = ga_credentials.AnonymousCredentials() |
3208 |
| - adc.return_value = (creds, None) |
3209 |
| - transport_class(quota_project_id="octopus") |
3210 |
| - |
3211 |
| - create_channel.assert_called_with( |
3212 |
| - "managedidentities.googleapis.com:443", |
3213 |
| - credentials=creds, |
3214 |
| - credentials_file=None, |
3215 |
| - quota_project_id="octopus", |
3216 |
| - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
3217 |
| - ssl_credentials=None, |
3218 |
| - options=[ |
3219 |
| - ("grpc.max_send_message_length", -1), |
3220 |
| - ("grpc.max_receive_message_length", -1), |
3221 |
| - ], |
3222 |
| - ) |
3223 |
| - |
3224 |
| - |
3225 |
| -@pytest.mark.parametrize( |
3226 |
| - "transport_class,grpc_helpers", |
3227 |
| - [ |
3228 |
| - (transports.ManagedIdentitiesServiceGrpcTransport, grpc_helpers), |
3229 |
| - (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3230 |
| - ], |
3231 |
| -) |
3232 |
| -@requires_api_core_lt_1_26_0 |
3233 |
| -def test_managed_identities_service_transport_create_channel_user_scopes( |
3234 |
| - transport_class, grpc_helpers |
3235 |
| -): |
3236 |
| - # If credentials and host are not provided, the transport class should use |
3237 |
| - # ADC credentials. |
3238 |
| - with mock.patch.object( |
3239 |
| - google.auth, "default", autospec=True |
3240 |
| - ) as adc, mock.patch.object( |
3241 |
| - grpc_helpers, "create_channel", autospec=True |
3242 |
| - ) as create_channel: |
3243 |
| - creds = ga_credentials.AnonymousCredentials() |
3244 |
| - adc.return_value = (creds, None) |
3245 |
| - |
3246 |
| - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
3247 |
| - |
3248 |
| - create_channel.assert_called_with( |
3249 |
| - "managedidentities.googleapis.com:443", |
3250 |
| - credentials=creds, |
3251 |
| - credentials_file=None, |
3252 |
| - quota_project_id="octopus", |
3253 |
| - scopes=["1", "2"], |
3254 |
| - ssl_credentials=None, |
3255 |
| - options=[ |
3256 |
| - ("grpc.max_send_message_length", -1), |
3257 |
| - ("grpc.max_receive_message_length", -1), |
3258 |
| - ], |
3259 |
| - ) |
3260 |
| - |
3261 |
| - |
3262 | 3189 | @pytest.mark.parametrize(
|
3263 | 3190 | "transport_class",
|
3264 | 3191 | [
|
|
0 commit comments