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

Commit 5c043fa

Browse files
fix: disable always_use_jwt_access (#65)
fix: disable always_use_jwt_access Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 36f7d83 commit 5c043fa

4 files changed

Lines changed: 31 additions & 28 deletions

File tree

‎google/area120/tables_v1alpha1/services/tables_service/transports/base.py‎

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

106106
# Save the scopes.
107-
self._scopes = scopes or self.AUTH_SCOPES
107+
self._scopes = scopes
108108

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

‎google/area120/tables_v1alpha1/services/tables_service/transports/grpc.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(
7171
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7272
quota_project_id: Optional[str] = None,
7373
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
74+
always_use_jwt_access: Optional[bool] = False,
7475
) -> None:
7576
"""Instantiate the transport.
7677
@@ -111,6 +112,8 @@ def __init__(
111112
API requests. If ``None``, then default info will be used.
112113
Generally, you only need to set this if you're developing
113114
your own client library.
115+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
116+
be used for service account credentials.
114117
115118
Raises:
116119
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/area120/tables_v1alpha1/services/tables_service/transports/grpc_asyncio.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def __init__(
117117
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
118118
quota_project_id=None,
119119
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
120+
always_use_jwt_access: Optional[bool] = False,
120121
) -> None:
121122
"""Instantiate the transport.
122123
@@ -158,6 +159,8 @@ def __init__(
158159
API requests. If ``None``, then default info will be used.
159160
Generally, you only need to set this if you're developing
160161
your own client library.
162+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
163+
be used for service account credentials.
161164
162165
Raises:
163166
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/tables_v1alpha1/test_tables_service.py‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,25 @@ def test_tables_service_client_service_account_always_use_jwt(client_class):
131131
) as use_jwt:
132132
creds = service_account.Credentials(None, None, None)
133133
client = client_class(credentials=creds)
134-
use_jwt.assert_called_with(True)
134+
use_jwt.assert_not_called()
135+
136+
137+
@pytest.mark.parametrize(
138+
"transport_class,transport_name",
139+
[
140+
(transports.TablesServiceGrpcTransport, "grpc"),
141+
(transports.TablesServiceGrpcAsyncIOTransport, "grpc_asyncio"),
142+
],
143+
)
144+
def test_tables_service_client_service_account_always_use_jwt_true(
145+
transport_class, transport_name
146+
):
147+
with mock.patch.object(
148+
service_account.Credentials, "with_always_use_jwt_access", create=True
149+
) as use_jwt:
150+
creds = service_account.Credentials(None, None, None)
151+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
152+
use_jwt.assert_called_once_with(True)
135153

136154

137155
@pytest.mark.parametrize(
@@ -3146,14 +3164,7 @@ def test_tables_service_grpc_transport_client_cert_source_for_mtls(transport_cla
31463164
"squid.clam.whelk:443",
31473165
credentials=cred,
31483166
credentials_file=None,
3149-
scopes=(
3150-
"https://www.googleapis.com/auth/drive",
3151-
"https://www.googleapis.com/auth/drive.file",
3152-
"https://www.googleapis.com/auth/drive.readonly",
3153-
"https://www.googleapis.com/auth/spreadsheets",
3154-
"https://www.googleapis.com/auth/spreadsheets.readonly",
3155-
"https://www.googleapis.com/auth/tables",
3156-
),
3167+
scopes=None,
31573168
ssl_credentials=mock_ssl_channel_creds,
31583169
quota_project_id=None,
31593170
options=[
@@ -3260,14 +3271,7 @@ def test_tables_service_transport_channel_mtls_with_client_cert_source(transport
32603271
"mtls.squid.clam.whelk:443",
32613272
credentials=cred,
32623273
credentials_file=None,
3263-
scopes=(
3264-
"https://www.googleapis.com/auth/drive",
3265-
"https://www.googleapis.com/auth/drive.file",
3266-
"https://www.googleapis.com/auth/drive.readonly",
3267-
"https://www.googleapis.com/auth/spreadsheets",
3268-
"https://www.googleapis.com/auth/spreadsheets.readonly",
3269-
"https://www.googleapis.com/auth/tables",
3270-
),
3274+
scopes=None,
32713275
ssl_credentials=mock_ssl_cred,
32723276
quota_project_id=None,
32733277
options=[
@@ -3314,14 +3318,7 @@ def test_tables_service_transport_channel_mtls_with_adc(transport_class):
33143318
"mtls.squid.clam.whelk:443",
33153319
credentials=mock_cred,
33163320
credentials_file=None,
3317-
scopes=(
3318-
"https://www.googleapis.com/auth/drive",
3319-
"https://www.googleapis.com/auth/drive.file",
3320-
"https://www.googleapis.com/auth/drive.readonly",
3321-
"https://www.googleapis.com/auth/spreadsheets",
3322-
"https://www.googleapis.com/auth/spreadsheets.readonly",
3323-
"https://www.googleapis.com/auth/tables",
3324-
),
3321+
scopes=None,
33253322
ssl_credentials=mock_ssl_cred,
33263323
quota_project_id=None,
33273324
options=[

0 commit comments

Comments
 (0)