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

Commit 81072d3

Browse files
fix: disable always_use_jwt_access (#81)
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 a909653 commit 81072d3

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/functions_v1/services/cloud_functions_service/transports/base.py

+1-1
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/functions_v1/services/cloud_functions_service/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6363
quota_project_id: Optional[str] = None,
6464
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
65+
always_use_jwt_access: Optional[bool] = False,
6566
) -> None:
6667
"""Instantiate the transport.
6768
@@ -102,6 +103,8 @@ def __init__(
102103
API requests. If ``None``, then default info will be used.
103104
Generally, you only need to set this if you're developing
104105
your own client library.
106+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
107+
be used for service account credentials.
105108
106109
Raises:
107110
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,7 +158,7 @@ def __init__(
155158
scopes=scopes,
156159
quota_project_id=quota_project_id,
157160
client_info=client_info,
158-
always_use_jwt_access=True,
161+
always_use_jwt_access=always_use_jwt_access,
159162
)
160163

161164
if not self._grpc_channel:

google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def __init__(
108108
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
109109
quota_project_id=None,
110110
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
111+
always_use_jwt_access: Optional[bool] = False,
111112
) -> None:
112113
"""Instantiate the transport.
113114
@@ -149,6 +150,8 @@ def __init__(
149150
API requests. If ``None``, then default info will be used.
150151
Generally, you only need to set this if you're developing
151152
your own client library.
153+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
154+
be used for service account credentials.
152155
153156
Raises:
154157
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,7 +204,7 @@ def __init__(
201204
scopes=scopes,
202205
quota_project_id=quota_project_id,
203206
client_info=client_info,
204-
always_use_jwt_access=True,
207+
always_use_jwt_access=always_use_jwt_access,
205208
)
206209

207210
if not self._grpc_channel:

tests/unit/gapic/functions_v1/test_cloud_functions_service.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,25 @@ def test_cloud_functions_service_client_service_account_always_use_jwt(client_cl
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.CloudFunctionsServiceGrpcTransport, "grpc"),
154+
(transports.CloudFunctionsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
155+
],
156+
)
157+
def test_cloud_functions_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(
@@ -3009,7 +3027,7 @@ def test_cloud_functions_service_grpc_transport_client_cert_source_for_mtls(
30093027
"squid.clam.whelk:443",
30103028
credentials=cred,
30113029
credentials_file=None,
3012-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3030+
scopes=None,
30133031
ssl_credentials=mock_ssl_channel_creds,
30143032
quota_project_id=None,
30153033
options=[
@@ -3118,7 +3136,7 @@ def test_cloud_functions_service_transport_channel_mtls_with_client_cert_source(
31183136
"mtls.squid.clam.whelk:443",
31193137
credentials=cred,
31203138
credentials_file=None,
3121-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3139+
scopes=None,
31223140
ssl_credentials=mock_ssl_cred,
31233141
quota_project_id=None,
31243142
options=[
@@ -3165,7 +3183,7 @@ def test_cloud_functions_service_transport_channel_mtls_with_adc(transport_class
31653183
"mtls.squid.clam.whelk:443",
31663184
credentials=mock_cred,
31673185
credentials_file=None,
3168-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3186+
scopes=None,
31693187
ssl_credentials=mock_ssl_cred,
31703188
quota_project_id=None,
31713189
options=[

0 commit comments

Comments
 (0)