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

Commit 37f28c5

Browse files
fix: disable always_use_jwt_access (#91)
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 ebcb552 commit 37f28c5

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

google/cloud/bigquery_connection_v1/services/connection_service/transports/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(
105105
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
106106

107107
# Save the scopes.
108-
self._scopes = scopes or self.AUTH_SCOPES
108+
self._scopes = scopes
109109

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

google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc.py

+4-1
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
@@ -153,7 +156,7 @@ def __init__(
153156
scopes=scopes,
154157
quota_project_id=quota_project_id,
155158
client_info=client_info,
156-
always_use_jwt_access=True,
159+
always_use_jwt_access=always_use_jwt_access,
157160
)
158161

159162
if not self._grpc_channel:

google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc_asyncio.py

+4-1
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
@@ -199,7 +202,7 @@ def __init__(
199202
scopes=scopes,
200203
quota_project_id=quota_project_id,
201204
client_info=client_info,
202-
always_use_jwt_access=True,
205+
always_use_jwt_access=always_use_jwt_access,
203206
)
204207

205208
if not self._grpc_channel:

tests/unit/gapic/bigquery_connection_v1/test_connection_service.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,25 @@ def test_connection_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.ConnectionServiceGrpcTransport, "grpc"),
148+
(transports.ConnectionServiceGrpcAsyncIOTransport, "grpc_asyncio"),
149+
],
150+
)
151+
def test_connection_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(
@@ -2782,10 +2800,7 @@ def test_connection_service_grpc_transport_client_cert_source_for_mtls(transport
27822800
"squid.clam.whelk:443",
27832801
credentials=cred,
27842802
credentials_file=None,
2785-
scopes=(
2786-
"https://www.googleapis.com/auth/bigquery",
2787-
"https://www.googleapis.com/auth/cloud-platform",
2788-
),
2803+
scopes=None,
27892804
ssl_credentials=mock_ssl_channel_creds,
27902805
quota_project_id=None,
27912806
options=[
@@ -2894,10 +2909,7 @@ def test_connection_service_transport_channel_mtls_with_client_cert_source(
28942909
"mtls.squid.clam.whelk:443",
28952910
credentials=cred,
28962911
credentials_file=None,
2897-
scopes=(
2898-
"https://www.googleapis.com/auth/bigquery",
2899-
"https://www.googleapis.com/auth/cloud-platform",
2900-
),
2912+
scopes=None,
29012913
ssl_credentials=mock_ssl_cred,
29022914
quota_project_id=None,
29032915
options=[
@@ -2944,10 +2956,7 @@ def test_connection_service_transport_channel_mtls_with_adc(transport_class):
29442956
"mtls.squid.clam.whelk:443",
29452957
credentials=mock_cred,
29462958
credentials_file=None,
2947-
scopes=(
2948-
"https://www.googleapis.com/auth/bigquery",
2949-
"https://www.googleapis.com/auth/cloud-platform",
2950-
),
2959+
scopes=None,
29512960
ssl_credentials=mock_ssl_cred,
29522961
quota_project_id=None,
29532962
options=[

0 commit comments

Comments
 (0)