Skip to content

Commit 2457a89

Browse files
fix: disable always_use_jwt_access (#126)
fix: disable always_use_jwt_access Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: googleapis/googleapis-gen@7b1e2c3
1 parent 0a8ebb2 commit 2457a89

4 files changed

Lines changed: 31 additions & 16 deletions

File tree

packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py

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

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def __init__(
7575
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7676
quota_project_id: Optional[str] = None,
7777
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
78+
always_use_jwt_access: Optional[bool] = False,
7879
) -> None:
7980
"""Instantiate the transport.
8081
@@ -115,6 +116,8 @@ def __init__(
115116
API requests. If ``None``, then default info will be used.
116117
Generally, you only need to set this if you're developing
117118
your own client library.
119+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
120+
be used for service account credentials.
118121
119122
Raises:
120123
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -167,7 +170,7 @@ def __init__(
167170
scopes=scopes,
168171
quota_project_id=quota_project_id,
169172
client_info=client_info,
170-
always_use_jwt_access=True,
173+
always_use_jwt_access=always_use_jwt_access,
171174
)
172175

173176
if not self._grpc_channel:

packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __init__(
121121
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
122122
quota_project_id=None,
123123
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
124+
always_use_jwt_access: Optional[bool] = False,
124125
) -> None:
125126
"""Instantiate the transport.
126127
@@ -162,6 +163,8 @@ def __init__(
162163
API requests. If ``None``, then default info will be used.
163164
Generally, you only need to set this if you're developing
164165
your own client library.
166+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
167+
be used for service account credentials.
165168
166169
Raises:
167170
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -213,7 +216,7 @@ def __init__(
213216
scopes=scopes,
214217
quota_project_id=quota_project_id,
215218
client_info=client_info,
216-
always_use_jwt_access=True,
219+
always_use_jwt_access=always_use_jwt_access,
217220
)
218221

219222
if not self._grpc_channel:

packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py

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

142160

143161
@pytest.mark.parametrize(
@@ -5902,10 +5920,7 @@ def test_reservation_service_grpc_transport_client_cert_source_for_mtls(
59025920
"squid.clam.whelk:443",
59035921
credentials=cred,
59045922
credentials_file=None,
5905-
scopes=(
5906-
"https://www.googleapis.com/auth/bigquery",
5907-
"https://www.googleapis.com/auth/cloud-platform",
5908-
),
5923+
scopes=None,
59095924
ssl_credentials=mock_ssl_channel_creds,
59105925
quota_project_id=None,
59115926
options=[
@@ -6014,10 +6029,7 @@ def test_reservation_service_transport_channel_mtls_with_client_cert_source(
60146029
"mtls.squid.clam.whelk:443",
60156030
credentials=cred,
60166031
credentials_file=None,
6017-
scopes=(
6018-
"https://www.googleapis.com/auth/bigquery",
6019-
"https://www.googleapis.com/auth/cloud-platform",
6020-
),
6032+
scopes=None,
60216033
ssl_credentials=mock_ssl_cred,
60226034
quota_project_id=None,
60236035
options=[
@@ -6064,10 +6076,7 @@ def test_reservation_service_transport_channel_mtls_with_adc(transport_class):
60646076
"mtls.squid.clam.whelk:443",
60656077
credentials=mock_cred,
60666078
credentials_file=None,
6067-
scopes=(
6068-
"https://www.googleapis.com/auth/bigquery",
6069-
"https://www.googleapis.com/auth/cloud-platform",
6070-
),
6079+
scopes=None,
60716080
ssl_credentials=mock_ssl_cred,
60726081
quota_project_id=None,
60736082
options=[

0 commit comments

Comments
 (0)