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

Commit 336ab30

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

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/notebooks_v1beta1/services/notebook_service/transports/base.py

Lines changed: 1 addition & 1 deletion
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/notebooks_v1beta1/services/notebook_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6262
quota_project_id: Optional[str] = None,
6363
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
64+
always_use_jwt_access: Optional[bool] = False,
6465
) -> None:
6566
"""Instantiate the transport.
6667
@@ -101,6 +102,8 @@ def __init__(
101102
API requests. If ``None``, then default info will be used.
102103
Generally, you only need to set this if you're developing
103104
your own client library.
105+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
106+
be used for service account credentials.
104107
105108
Raises:
106109
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -154,7 +157,7 @@ def __init__(
154157
scopes=scopes,
155158
quota_project_id=quota_project_id,
156159
client_info=client_info,
157-
always_use_jwt_access=True,
160+
always_use_jwt_access=always_use_jwt_access,
158161
)
159162

160163
if not self._grpc_channel:

google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def __init__(
107107
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
108108
quota_project_id=None,
109109
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
110+
always_use_jwt_access: Optional[bool] = False,
110111
) -> None:
111112
"""Instantiate the transport.
112113
@@ -148,6 +149,8 @@ def __init__(
148149
API requests. If ``None``, then default info will be used.
149150
Generally, you only need to set this if you're developing
150151
your own client library.
152+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
153+
be used for service account credentials.
151154
152155
Raises:
153156
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -200,7 +203,7 @@ def __init__(
200203
scopes=scopes,
201204
quota_project_id=quota_project_id,
202205
client_info=client_info,
203-
always_use_jwt_access=True,
206+
always_use_jwt_access=always_use_jwt_access,
204207
)
205208

206209
if not self._grpc_channel:

tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,25 @@ def test_notebook_service_client_service_account_always_use_jwt(client_class):
138138
) as use_jwt:
139139
creds = service_account.Credentials(None, None, None)
140140
client = client_class(credentials=creds)
141-
use_jwt.assert_called_with(True)
141+
use_jwt.assert_not_called()
142+
143+
144+
@pytest.mark.parametrize(
145+
"transport_class,transport_name",
146+
[
147+
(transports.NotebookServiceGrpcTransport, "grpc"),
148+
(transports.NotebookServiceGrpcAsyncIOTransport, "grpc_asyncio"),
149+
],
150+
)
151+
def test_notebook_service_client_service_account_always_use_jwt_true(
152+
transport_class, transport_name
153+
):
154+
with mock.patch.object(
155+
service_account.Credentials, "with_always_use_jwt_access", create=True
156+
) as use_jwt:
157+
creds = service_account.Credentials(None, None, None)
158+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
159+
use_jwt.assert_called_once_with(True)
142160

143161

144162
@pytest.mark.parametrize(
@@ -3830,7 +3848,7 @@ def test_notebook_service_grpc_transport_client_cert_source_for_mtls(transport_c
38303848
"squid.clam.whelk:443",
38313849
credentials=cred,
38323850
credentials_file=None,
3833-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3851+
scopes=None,
38343852
ssl_credentials=mock_ssl_channel_creds,
38353853
quota_project_id=None,
38363854
options=[
@@ -3939,7 +3957,7 @@ def test_notebook_service_transport_channel_mtls_with_client_cert_source(
39393957
"mtls.squid.clam.whelk:443",
39403958
credentials=cred,
39413959
credentials_file=None,
3942-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3960+
scopes=None,
39433961
ssl_credentials=mock_ssl_cred,
39443962
quota_project_id=None,
39453963
options=[
@@ -3986,7 +4004,7 @@ def test_notebook_service_transport_channel_mtls_with_adc(transport_class):
39864004
"mtls.squid.clam.whelk:443",
39874005
credentials=mock_cred,
39884006
credentials_file=None,
3989-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4007+
scopes=None,
39904008
ssl_credentials=mock_ssl_cred,
39914009
quota_project_id=None,
39924010
options=[

0 commit comments

Comments
 (0)