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

Commit 8c50b89

Browse files
fix: disable always_use_jwt_access (#117)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent f3f3797 commit 8c50b89

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/base.py

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

113113
# Save the scopes.
114-
self._scopes = scopes or self.AUTH_SCOPES
114+
self._scopes = scopes
115115

116116
# If no credentials are provided, then determine the appropriate
117117
# defaults.

google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(
7070
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7171
quota_project_id: Optional[str] = None,
7272
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
73+
always_use_jwt_access: Optional[bool] = False,
7374
) -> None:
7475
"""Instantiate the transport.
7576
@@ -110,6 +111,8 @@ def __init__(
110111
API requests. If ``None``, then default info will be used.
111112
Generally, you only need to set this if you're developing
112113
your own client library.
114+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
115+
be used for service account credentials.
113116
114117
Raises:
115118
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -163,7 +166,7 @@ def __init__(
163166
scopes=scopes,
164167
quota_project_id=quota_project_id,
165168
client_info=client_info,
166-
always_use_jwt_access=True,
169+
always_use_jwt_access=always_use_jwt_access,
167170
)
168171

169172
if not self._grpc_channel:

google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __init__(
116116
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
117117
quota_project_id=None,
118118
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
119+
always_use_jwt_access: Optional[bool] = False,
119120
) -> None:
120121
"""Instantiate the transport.
121122
@@ -157,6 +158,8 @@ def __init__(
157158
API requests. If ``None``, then default info will be used.
158159
Generally, you only need to set this if you're developing
159160
your own client library.
161+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
162+
be used for service account credentials.
160163
161164
Raises:
162165
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -209,7 +212,7 @@ def __init__(
209212
scopes=scopes,
210213
quota_project_id=quota_project_id,
211214
client_info=client_info,
212-
always_use_jwt_access=True,
215+
always_use_jwt_access=always_use_jwt_access,
213216
)
214217

215218
if not self._grpc_channel:

tests/unit/gapic/datalabeling_v1beta1/test_data_labeling_service.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,25 @@ def test_data_labeling_service_client_service_account_always_use_jwt(client_clas
156156
) as use_jwt:
157157
creds = service_account.Credentials(None, None, None)
158158
client = client_class(credentials=creds)
159-
use_jwt.assert_called_with(True)
159+
use_jwt.assert_not_called()
160+
161+
162+
@pytest.mark.parametrize(
163+
"transport_class,transport_name",
164+
[
165+
(transports.DataLabelingServiceGrpcTransport, "grpc"),
166+
(transports.DataLabelingServiceGrpcAsyncIOTransport, "grpc_asyncio"),
167+
],
168+
)
169+
def test_data_labeling_service_client_service_account_always_use_jwt_true(
170+
transport_class, transport_name
171+
):
172+
with mock.patch.object(
173+
service_account.Credentials, "with_always_use_jwt_access", create=True
174+
) as use_jwt:
175+
creds = service_account.Credentials(None, None, None)
176+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
177+
use_jwt.assert_called_once_with(True)
160178

161179

162180
@pytest.mark.parametrize(
@@ -10130,7 +10148,7 @@ def test_data_labeling_service_grpc_transport_client_cert_source_for_mtls(
1013010148
"squid.clam.whelk:443",
1013110149
credentials=cred,
1013210150
credentials_file=None,
10133-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
10151+
scopes=None,
1013410152
ssl_credentials=mock_ssl_channel_creds,
1013510153
quota_project_id=None,
1013610154
options=[
@@ -10239,7 +10257,7 @@ def test_data_labeling_service_transport_channel_mtls_with_client_cert_source(
1023910257
"mtls.squid.clam.whelk:443",
1024010258
credentials=cred,
1024110259
credentials_file=None,
10242-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
10260+
scopes=None,
1024310261
ssl_credentials=mock_ssl_cred,
1024410262
quota_project_id=None,
1024510263
options=[
@@ -10286,7 +10304,7 @@ def test_data_labeling_service_transport_channel_mtls_with_adc(transport_class):
1028610304
"mtls.squid.clam.whelk:443",
1028710305
credentials=mock_cred,
1028810306
credentials_file=None,
10289-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
10307+
scopes=None,
1029010308
ssl_credentials=mock_ssl_cred,
1029110309
quota_project_id=None,
1029210310
options=[

0 commit comments

Comments
 (0)