|
39 | 39 | ) |
40 | 40 | from google.cloud.secretmanager_v1.services.secret_manager_service import pagers |
41 | 41 | from google.cloud.secretmanager_v1.services.secret_manager_service import transports |
42 | | -from google.cloud.secretmanager_v1.services.secret_manager_service.transports.base import ( |
43 | | - _API_CORE_VERSION, |
44 | | -) |
45 | 42 | from google.cloud.secretmanager_v1.services.secret_manager_service.transports.base import ( |
46 | 43 | _GOOGLE_AUTH_VERSION, |
47 | 44 | ) |
|
58 | 55 | import google.auth |
59 | 56 |
|
60 | 57 |
|
61 | | -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
62 | | -# - Delete all the api-core and auth "less than" test cases |
| 58 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 59 | +# through google-api-core: |
| 60 | +# - Delete the auth "less than" test cases |
63 | 61 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default). |
64 | 62 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif( |
65 | 63 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), |
|
70 | 68 | reason="This test requires google-auth >= 1.25.0", |
71 | 69 | ) |
72 | 70 |
|
73 | | -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
74 | | - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
75 | | - reason="This test requires google-api-core < 1.26.0", |
76 | | -) |
77 | | - |
78 | | -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
79 | | - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
80 | | - reason="This test requires google-api-core >= 1.26.0", |
81 | | -) |
82 | | - |
83 | 71 |
|
84 | 72 | def client_cert_source_callback(): |
85 | 73 | return b"cert bytes", b"key bytes" |
@@ -143,6 +131,18 @@ def test_secret_manager_service_client_from_service_account_info(client_class): |
143 | 131 | assert client.transport._host == "secretmanager.googleapis.com:443" |
144 | 132 |
|
145 | 133 |
|
| 134 | +@pytest.mark.parametrize( |
| 135 | + "client_class", [SecretManagerServiceClient, SecretManagerServiceAsyncClient,] |
| 136 | +) |
| 137 | +def test_secret_manager_service_client_service_account_always_use_jwt(client_class): |
| 138 | + with mock.patch.object( |
| 139 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 140 | + ) as use_jwt: |
| 141 | + creds = service_account.Credentials(None, None, None) |
| 142 | + client = client_class(credentials=creds) |
| 143 | + use_jwt.assert_called_with(True) |
| 144 | + |
| 145 | + |
146 | 146 | @pytest.mark.parametrize( |
147 | 147 | "client_class", [SecretManagerServiceClient, SecretManagerServiceAsyncClient,] |
148 | 148 | ) |
@@ -4211,7 +4211,6 @@ def test_secret_manager_service_transport_auth_adc_old_google_auth(transport_cla |
4211 | 4211 | (transports.SecretManagerServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4212 | 4212 | ], |
4213 | 4213 | ) |
4214 | | -@requires_api_core_gte_1_26_0 |
4215 | 4214 | def test_secret_manager_service_transport_create_channel(transport_class, grpc_helpers): |
4216 | 4215 | # If credentials and host are not provided, the transport class should use |
4217 | 4216 | # ADC credentials. |
@@ -4240,79 +4239,6 @@ def test_secret_manager_service_transport_create_channel(transport_class, grpc_h |
4240 | 4239 | ) |
4241 | 4240 |
|
4242 | 4241 |
|
4243 | | -@pytest.mark.parametrize( |
4244 | | - "transport_class,grpc_helpers", |
4245 | | - [ |
4246 | | - (transports.SecretManagerServiceGrpcTransport, grpc_helpers), |
4247 | | - (transports.SecretManagerServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4248 | | - ], |
4249 | | -) |
4250 | | -@requires_api_core_lt_1_26_0 |
4251 | | -def test_secret_manager_service_transport_create_channel_old_api_core( |
4252 | | - transport_class, grpc_helpers |
4253 | | -): |
4254 | | - # If credentials and host are not provided, the transport class should use |
4255 | | - # ADC credentials. |
4256 | | - with mock.patch.object( |
4257 | | - google.auth, "default", autospec=True |
4258 | | - ) as adc, mock.patch.object( |
4259 | | - grpc_helpers, "create_channel", autospec=True |
4260 | | - ) as create_channel: |
4261 | | - creds = ga_credentials.AnonymousCredentials() |
4262 | | - adc.return_value = (creds, None) |
4263 | | - transport_class(quota_project_id="octopus") |
4264 | | - |
4265 | | - create_channel.assert_called_with( |
4266 | | - "secretmanager.googleapis.com:443", |
4267 | | - credentials=creds, |
4268 | | - credentials_file=None, |
4269 | | - quota_project_id="octopus", |
4270 | | - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
4271 | | - ssl_credentials=None, |
4272 | | - options=[ |
4273 | | - ("grpc.max_send_message_length", -1), |
4274 | | - ("grpc.max_receive_message_length", -1), |
4275 | | - ], |
4276 | | - ) |
4277 | | - |
4278 | | - |
4279 | | -@pytest.mark.parametrize( |
4280 | | - "transport_class,grpc_helpers", |
4281 | | - [ |
4282 | | - (transports.SecretManagerServiceGrpcTransport, grpc_helpers), |
4283 | | - (transports.SecretManagerServiceGrpcAsyncIOTransport, grpc_helpers_async), |
4284 | | - ], |
4285 | | -) |
4286 | | -@requires_api_core_lt_1_26_0 |
4287 | | -def test_secret_manager_service_transport_create_channel_user_scopes( |
4288 | | - transport_class, grpc_helpers |
4289 | | -): |
4290 | | - # If credentials and host are not provided, the transport class should use |
4291 | | - # ADC credentials. |
4292 | | - with mock.patch.object( |
4293 | | - google.auth, "default", autospec=True |
4294 | | - ) as adc, mock.patch.object( |
4295 | | - grpc_helpers, "create_channel", autospec=True |
4296 | | - ) as create_channel: |
4297 | | - creds = ga_credentials.AnonymousCredentials() |
4298 | | - adc.return_value = (creds, None) |
4299 | | - |
4300 | | - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
4301 | | - |
4302 | | - create_channel.assert_called_with( |
4303 | | - "secretmanager.googleapis.com:443", |
4304 | | - credentials=creds, |
4305 | | - credentials_file=None, |
4306 | | - quota_project_id="octopus", |
4307 | | - scopes=["1", "2"], |
4308 | | - ssl_credentials=None, |
4309 | | - options=[ |
4310 | | - ("grpc.max_send_message_length", -1), |
4311 | | - ("grpc.max_receive_message_length", -1), |
4312 | | - ], |
4313 | | - ) |
4314 | | - |
4315 | | - |
4316 | 4242 | @pytest.mark.parametrize( |
4317 | 4243 | "transport_class", |
4318 | 4244 | [ |
|
0 commit comments