Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 903b08e

Browse files
fix: disable always_use_jwt_access (#47)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 73897e4 commit 903b08e

File tree

12 files changed

+93
-21
lines changed

12 files changed

+93
-21
lines changed

google/cloud/metastore_v1/services/dataproc_metastore/transports/base.py

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

100100
# Save the scopes.
101-
self._scopes = scopes or self.AUTH_SCOPES
101+
self._scopes = scopes
102102

103103
# If no credentials are provided, then determine the appropriate
104104
# defaults.

google/cloud/metastore_v1/services/dataproc_metastore/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(
8181
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
8282
quota_project_id: Optional[str] = None,
8383
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
84+
always_use_jwt_access: Optional[bool] = False,
8485
) -> None:
8586
"""Instantiate the transport.
8687
@@ -121,6 +122,8 @@ def __init__(
121122
API requests. If ``None``, then default info will be used.
122123
Generally, you only need to set this if you're developing
123124
your own client library.
125+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
126+
be used for service account credentials.
124127
125128
Raises:
126129
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -174,7 +177,7 @@ def __init__(
174177
scopes=scopes,
175178
quota_project_id=quota_project_id,
176179
client_info=client_info,
177-
always_use_jwt_access=True,
180+
always_use_jwt_access=always_use_jwt_access,
178181
)
179182

180183
if not self._grpc_channel:

google/cloud/metastore_v1/services/dataproc_metastore/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def __init__(
127127
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
128128
quota_project_id=None,
129129
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
130+
always_use_jwt_access: Optional[bool] = False,
130131
) -> None:
131132
"""Instantiate the transport.
132133
@@ -168,6 +169,8 @@ def __init__(
168169
API requests. If ``None``, then default info will be used.
169170
Generally, you only need to set this if you're developing
170171
your own client library.
172+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
173+
be used for service account credentials.
171174
172175
Raises:
173176
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -220,7 +223,7 @@ def __init__(
220223
scopes=scopes,
221224
quota_project_id=quota_project_id,
222225
client_info=client_info,
223-
always_use_jwt_access=True,
226+
always_use_jwt_access=always_use_jwt_access,
224227
)
225228

226229
if not self._grpc_channel:

google/cloud/metastore_v1alpha/services/dataproc_metastore/transports/base.py

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

100100
# Save the scopes.
101-
self._scopes = scopes or self.AUTH_SCOPES
101+
self._scopes = scopes
102102

103103
# If no credentials are provided, then determine the appropriate
104104
# defaults.

google/cloud/metastore_v1alpha/services/dataproc_metastore/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(
8181
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
8282
quota_project_id: Optional[str] = None,
8383
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
84+
always_use_jwt_access: Optional[bool] = False,
8485
) -> None:
8586
"""Instantiate the transport.
8687
@@ -121,6 +122,8 @@ def __init__(
121122
API requests. If ``None``, then default info will be used.
122123
Generally, you only need to set this if you're developing
123124
your own client library.
125+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
126+
be used for service account credentials.
124127
125128
Raises:
126129
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -174,7 +177,7 @@ def __init__(
174177
scopes=scopes,
175178
quota_project_id=quota_project_id,
176179
client_info=client_info,
177-
always_use_jwt_access=True,
180+
always_use_jwt_access=always_use_jwt_access,
178181
)
179182

180183
if not self._grpc_channel:

google/cloud/metastore_v1alpha/services/dataproc_metastore/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def __init__(
127127
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
128128
quota_project_id=None,
129129
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
130+
always_use_jwt_access: Optional[bool] = False,
130131
) -> None:
131132
"""Instantiate the transport.
132133
@@ -168,6 +169,8 @@ def __init__(
168169
API requests. If ``None``, then default info will be used.
169170
Generally, you only need to set this if you're developing
170171
your own client library.
172+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
173+
be used for service account credentials.
171174
172175
Raises:
173176
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -220,7 +223,7 @@ def __init__(
220223
scopes=scopes,
221224
quota_project_id=quota_project_id,
222225
client_info=client_info,
223-
always_use_jwt_access=True,
226+
always_use_jwt_access=always_use_jwt_access,
224227
)
225228

226229
if not self._grpc_channel:

google/cloud/metastore_v1beta/services/dataproc_metastore/transports/base.py

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

102102
# Save the scopes.
103-
self._scopes = scopes or self.AUTH_SCOPES
103+
self._scopes = scopes
104104

105105
# If no credentials are provided, then determine the appropriate
106106
# defaults.

google/cloud/metastore_v1beta/services/dataproc_metastore/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(
8181
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
8282
quota_project_id: Optional[str] = None,
8383
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
84+
always_use_jwt_access: Optional[bool] = False,
8485
) -> None:
8586
"""Instantiate the transport.
8687
@@ -121,6 +122,8 @@ def __init__(
121122
API requests. If ``None``, then default info will be used.
122123
Generally, you only need to set this if you're developing
123124
your own client library.
125+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
126+
be used for service account credentials.
124127
125128
Raises:
126129
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -174,7 +177,7 @@ def __init__(
174177
scopes=scopes,
175178
quota_project_id=quota_project_id,
176179
client_info=client_info,
177-
always_use_jwt_access=True,
180+
always_use_jwt_access=always_use_jwt_access,
178181
)
179182

180183
if not self._grpc_channel:

google/cloud/metastore_v1beta/services/dataproc_metastore/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def __init__(
127127
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
128128
quota_project_id=None,
129129
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
130+
always_use_jwt_access: Optional[bool] = False,
130131
) -> None:
131132
"""Instantiate the transport.
132133
@@ -168,6 +169,8 @@ def __init__(
168169
API requests. If ``None``, then default info will be used.
169170
Generally, you only need to set this if you're developing
170171
your own client library.
172+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
173+
be used for service account credentials.
171174
172175
Raises:
173176
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -220,7 +223,7 @@ def __init__(
220223
scopes=scopes,
221224
quota_project_id=quota_project_id,
222225
client_info=client_info,
223-
always_use_jwt_access=True,
226+
always_use_jwt_access=always_use_jwt_access,
224227
)
225228

226229
if not self._grpc_channel:

tests/unit/gapic/metastore_v1/test_dataproc_metastore.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,25 @@ def test_dataproc_metastore_client_service_account_always_use_jwt(client_class):
140140
) as use_jwt:
141141
creds = service_account.Credentials(None, None, None)
142142
client = client_class(credentials=creds)
143-
use_jwt.assert_called_with(True)
143+
use_jwt.assert_not_called()
144+
145+
146+
@pytest.mark.parametrize(
147+
"transport_class,transport_name",
148+
[
149+
(transports.DataprocMetastoreGrpcTransport, "grpc"),
150+
(transports.DataprocMetastoreGrpcAsyncIOTransport, "grpc_asyncio"),
151+
],
152+
)
153+
def test_dataproc_metastore_client_service_account_always_use_jwt_true(
154+
transport_class, transport_name
155+
):
156+
with mock.patch.object(
157+
service_account.Credentials, "with_always_use_jwt_access", create=True
158+
) as use_jwt:
159+
creds = service_account.Credentials(None, None, None)
160+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
161+
use_jwt.assert_called_once_with(True)
144162

145163

146164
@pytest.mark.parametrize(
@@ -3319,7 +3337,7 @@ def test_dataproc_metastore_grpc_transport_client_cert_source_for_mtls(transport
33193337
"squid.clam.whelk:443",
33203338
credentials=cred,
33213339
credentials_file=None,
3322-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3340+
scopes=None,
33233341
ssl_credentials=mock_ssl_channel_creds,
33243342
quota_project_id=None,
33253343
options=[
@@ -3428,7 +3446,7 @@ def test_dataproc_metastore_transport_channel_mtls_with_client_cert_source(
34283446
"mtls.squid.clam.whelk:443",
34293447
credentials=cred,
34303448
credentials_file=None,
3431-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3449+
scopes=None,
34323450
ssl_credentials=mock_ssl_cred,
34333451
quota_project_id=None,
34343452
options=[
@@ -3475,7 +3493,7 @@ def test_dataproc_metastore_transport_channel_mtls_with_adc(transport_class):
34753493
"mtls.squid.clam.whelk:443",
34763494
credentials=mock_cred,
34773495
credentials_file=None,
3478-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3496+
scopes=None,
34793497
ssl_credentials=mock_ssl_cred,
34803498
quota_project_id=None,
34813499
options=[

0 commit comments

Comments
 (0)