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

Commit de8c214

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

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/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/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
5959
quota_project_id: Optional[str] = None,
6060
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
61+
always_use_jwt_access: Optional[bool] = False,
6162
) -> None:
6263
"""Instantiate the transport.
6364
@@ -98,6 +99,8 @@ def __init__(
9899
API requests. If ``None``, then default info will be used.
99100
Generally, you only need to set this if you're developing
100101
your own client library.
102+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
103+
be used for service account credentials.
101104
102105
Raises:
103106
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -150,7 +153,7 @@ def __init__(
150153
scopes=scopes,
151154
quota_project_id=quota_project_id,
152155
client_info=client_info,
153-
always_use_jwt_access=True,
156+
always_use_jwt_access=always_use_jwt_access,
154157
)
155158

156159
if not self._grpc_channel:

‎google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__(
106106
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
107107
quota_project_id=None,
108108
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
109+
always_use_jwt_access: Optional[bool] = False,
109110
) -> None:
110111
"""Instantiate the transport.
111112
@@ -147,6 +148,8 @@ def __init__(
147148
API requests. If ``None``, then default info will be used.
148149
Generally, you only need to set this if you're developing
149150
your own client library.
151+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
152+
be used for service account credentials.
150153
151154
Raises:
152155
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -198,7 +201,7 @@ def __init__(
198201
scopes=scopes,
199202
quota_project_id=quota_project_id,
200203
client_info=client_info,
201-
always_use_jwt_access=True,
204+
always_use_jwt_access=always_use_jwt_access,
202205
)
203206

204207
if not self._grpc_channel:

‎tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,25 @@ def test_recaptcha_enterprise_service_client_service_account_always_use_jwt(
144144
) as use_jwt:
145145
creds = service_account.Credentials(None, None, None)
146146
client = client_class(credentials=creds)
147-
use_jwt.assert_called_with(True)
147+
use_jwt.assert_not_called()
148+
149+
150+
@pytest.mark.parametrize(
151+
"transport_class,transport_name",
152+
[
153+
(transports.RecaptchaEnterpriseServiceGrpcTransport, "grpc"),
154+
(transports.RecaptchaEnterpriseServiceGrpcAsyncIOTransport, "grpc_asyncio"),
155+
],
156+
)
157+
def test_recaptcha_enterprise_service_client_service_account_always_use_jwt_true(
158+
transport_class, transport_name
159+
):
160+
with mock.patch.object(
161+
service_account.Credentials, "with_always_use_jwt_access", create=True
162+
) as use_jwt:
163+
creds = service_account.Credentials(None, None, None)
164+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
165+
use_jwt.assert_called_once_with(True)
148166

149167

150168
@pytest.mark.parametrize(
@@ -2132,7 +2150,7 @@ def test_recaptcha_enterprise_service_grpc_transport_client_cert_source_for_mtls
21322150
"squid.clam.whelk:443",
21332151
credentials=cred,
21342152
credentials_file=None,
2135-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2153+
scopes=None,
21362154
ssl_credentials=mock_ssl_channel_creds,
21372155
quota_project_id=None,
21382156
options=[
@@ -2241,7 +2259,7 @@ def test_recaptcha_enterprise_service_transport_channel_mtls_with_client_cert_so
22412259
"mtls.squid.clam.whelk:443",
22422260
credentials=cred,
22432261
credentials_file=None,
2244-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2262+
scopes=None,
22452263
ssl_credentials=mock_ssl_cred,
22462264
quota_project_id=None,
22472265
options=[
@@ -2288,7 +2306,7 @@ def test_recaptcha_enterprise_service_transport_channel_mtls_with_adc(transport_
22882306
"mtls.squid.clam.whelk:443",
22892307
credentials=mock_cred,
22902308
credentials_file=None,
2291-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2309+
scopes=None,
22922310
ssl_credentials=mock_ssl_cred,
22932311
quota_project_id=None,
22942312
options=[

0 commit comments

Comments
 (0)