Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 54d2286

Browse files
fix: disable always_use_jwt_access (#126)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 208b8d7 commit 54d2286

File tree

12 files changed

+93
-21
lines changed

12 files changed

+93
-21
lines changed

google/cloud/tasks_v2/services/cloud_tasks/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
104104

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6666
quota_project_id: Optional[str] = None,
6767
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
68+
always_use_jwt_access: Optional[bool] = False,
6869
) -> None:
6970
"""Instantiate the transport.
7071
@@ -105,6 +106,8 @@ def __init__(
105106
API requests. If ``None``, then default info will be used.
106107
Generally, you only need to set this if you're developing
107108
your own client library.
109+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
110+
be used for service account credentials.
108111
109112
Raises:
110113
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -157,7 +160,7 @@ def __init__(
157160
scopes=scopes,
158161
quota_project_id=quota_project_id,
159162
client_info=client_info,
160-
always_use_jwt_access=True,
163+
always_use_jwt_access=always_use_jwt_access,
161164
)
162165

163166
if not self._grpc_channel:

google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
104104

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6666
quota_project_id: Optional[str] = None,
6767
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
68+
always_use_jwt_access: Optional[bool] = False,
6869
) -> None:
6970
"""Instantiate the transport.
7071
@@ -105,6 +106,8 @@ def __init__(
105106
API requests. If ``None``, then default info will be used.
106107
Generally, you only need to set this if you're developing
107108
your own client library.
109+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
110+
be used for service account credentials.
108111
109112
Raises:
110113
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -157,7 +160,7 @@ def __init__(
157160
scopes=scopes,
158161
quota_project_id=quota_project_id,
159162
client_info=client_info,
160-
always_use_jwt_access=True,
163+
always_use_jwt_access=always_use_jwt_access,
161164
)
162165

163166
if not self._grpc_channel:

google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
104104

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6666
quota_project_id: Optional[str] = None,
6767
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
68+
always_use_jwt_access: Optional[bool] = False,
6869
) -> None:
6970
"""Instantiate the transport.
7071
@@ -105,6 +106,8 @@ def __init__(
105106
API requests. If ``None``, then default info will be used.
106107
Generally, you only need to set this if you're developing
107108
your own client library.
109+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
110+
be used for service account credentials.
108111
109112
Raises:
110113
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -157,7 +160,7 @@ def __init__(
157160
scopes=scopes,
158161
quota_project_id=quota_project_id,
159162
client_info=client_info,
160-
always_use_jwt_access=True,
163+
always_use_jwt_access=always_use_jwt_access,
161164
)
162165

163166
if not self._grpc_channel:

google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

tests/unit/gapic/tasks_v2/test_cloud_tasks.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,25 @@ def test_cloud_tasks_client_service_account_always_use_jwt(client_class):
134134
) as use_jwt:
135135
creds = service_account.Credentials(None, None, None)
136136
client = client_class(credentials=creds)
137-
use_jwt.assert_called_with(True)
137+
use_jwt.assert_not_called()
138+
139+
140+
@pytest.mark.parametrize(
141+
"transport_class,transport_name",
142+
[
143+
(transports.CloudTasksGrpcTransport, "grpc"),
144+
(transports.CloudTasksGrpcAsyncIOTransport, "grpc_asyncio"),
145+
],
146+
)
147+
def test_cloud_tasks_client_service_account_always_use_jwt_true(
148+
transport_class, transport_name
149+
):
150+
with mock.patch.object(
151+
service_account.Credentials, "with_always_use_jwt_access", create=True
152+
) as use_jwt:
153+
creds = service_account.Credentials(None, None, None)
154+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
155+
use_jwt.assert_called_once_with(True)
138156

139157

140158
@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,])
@@ -4233,7 +4251,7 @@ def test_cloud_tasks_grpc_transport_client_cert_source_for_mtls(transport_class)
42334251
"squid.clam.whelk:443",
42344252
credentials=cred,
42354253
credentials_file=None,
4236-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4254+
scopes=None,
42374255
ssl_credentials=mock_ssl_channel_creds,
42384256
quota_project_id=None,
42394257
options=[
@@ -4337,7 +4355,7 @@ def test_cloud_tasks_transport_channel_mtls_with_client_cert_source(transport_cl
43374355
"mtls.squid.clam.whelk:443",
43384356
credentials=cred,
43394357
credentials_file=None,
4340-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4358+
scopes=None,
43414359
ssl_credentials=mock_ssl_cred,
43424360
quota_project_id=None,
43434361
options=[
@@ -4381,7 +4399,7 @@ def test_cloud_tasks_transport_channel_mtls_with_adc(transport_class):
43814399
"mtls.squid.clam.whelk:443",
43824400
credentials=mock_cred,
43834401
credentials_file=None,
4384-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4402+
scopes=None,
43854403
ssl_credentials=mock_ssl_cred,
43864404
quota_project_id=None,
43874405
options=[

0 commit comments

Comments
 (0)