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

Commit e4e04a0

Browse files
fix: disable always_use_jwt_access (#93)
fix: disable always_use_jwt_access Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: googleapis/googleapis-gen@7b1e2c3
1 parent 41eb0a8 commit e4e04a0

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/accessapproval_v1/services/access_approval/transports/base.py

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

101101
# Save the scopes.
102-
self._scopes = scopes or self.AUTH_SCOPES
102+
self._scopes = scopes
103103

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

google/cloud/accessapproval_v1/services/access_approval/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def __init__(
9292
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
9393
quota_project_id: Optional[str] = None,
9494
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
95+
always_use_jwt_access: Optional[bool] = False,
9596
) -> None:
9697
"""Instantiate the transport.
9798
@@ -132,6 +133,8 @@ def __init__(
132133
API requests. If ``None``, then default info will be used.
133134
Generally, you only need to set this if you're developing
134135
your own client library.
136+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
137+
be used for service account credentials.
135138
136139
Raises:
137140
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -184,7 +187,7 @@ def __init__(
184187
scopes=scopes,
185188
quota_project_id=quota_project_id,
186189
client_info=client_info,
187-
always_use_jwt_access=True,
190+
always_use_jwt_access=always_use_jwt_access,
188191
)
189192

190193
if not self._grpc_channel:

google/cloud/accessapproval_v1/services/access_approval/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def __init__(
138138
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
139139
quota_project_id=None,
140140
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
141+
always_use_jwt_access: Optional[bool] = False,
141142
) -> None:
142143
"""Instantiate the transport.
143144
@@ -179,6 +180,8 @@ def __init__(
179180
API requests. If ``None``, then default info will be used.
180181
Generally, you only need to set this if you're developing
181182
your own client library.
183+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
184+
be used for service account credentials.
182185
183186
Raises:
184187
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -230,7 +233,7 @@ def __init__(
230233
scopes=scopes,
231234
quota_project_id=quota_project_id,
232235
client_info=client_info,
233-
always_use_jwt_access=True,
236+
always_use_jwt_access=always_use_jwt_access,
234237
)
235238

236239
if not self._grpc_channel:

tests/unit/gapic/accessapproval_v1/test_access_approval.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,25 @@ def test_access_approval_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.AccessApprovalGrpcTransport, "grpc"),
141+
(transports.AccessApprovalGrpcAsyncIOTransport, "grpc_asyncio"),
142+
],
143+
)
144+
def test_access_approval_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(
@@ -2381,7 +2399,7 @@ def test_access_approval_grpc_transport_client_cert_source_for_mtls(transport_cl
23812399
"squid.clam.whelk:443",
23822400
credentials=cred,
23832401
credentials_file=None,
2384-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2402+
scopes=None,
23852403
ssl_credentials=mock_ssl_channel_creds,
23862404
quota_project_id=None,
23872405
options=[
@@ -2490,7 +2508,7 @@ def test_access_approval_transport_channel_mtls_with_client_cert_source(
24902508
"mtls.squid.clam.whelk:443",
24912509
credentials=cred,
24922510
credentials_file=None,
2493-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2511+
scopes=None,
24942512
ssl_credentials=mock_ssl_cred,
24952513
quota_project_id=None,
24962514
options=[
@@ -2537,7 +2555,7 @@ def test_access_approval_transport_channel_mtls_with_adc(transport_class):
25372555
"mtls.squid.clam.whelk:443",
25382556
credentials=mock_cred,
25392557
credentials_file=None,
2540-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2558+
scopes=None,
25412559
ssl_credentials=mock_ssl_cred,
25422560
quota_project_id=None,
25432561
options=[

0 commit comments

Comments
 (0)