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

Commit 3a2782a

Browse files
fix: disable always_use_jwt_access (#11)
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 4266c6a commit 3a2782a

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/resourcesettings_v1/services/resource_settings_service/transports/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
9999

100100
# Save the scopes.
101-
self._scopes = scopes or self.AUTH_SCOPES
101+
self._scopes = scopes
102102

103103
# If no credentials are provided, then determine the appropriate
104104
# defaults.

google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(
6969
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7070
quota_project_id: Optional[str] = None,
7171
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
72+
always_use_jwt_access: Optional[bool] = False,
7273
) -> None:
7374
"""Instantiate the transport.
7475
@@ -109,6 +110,8 @@ def __init__(
109110
API requests. If ``None``, then default info will be used.
110111
Generally, you only need to set this if you're developing
111112
your own client library.
113+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
114+
be used for service account credentials.
112115
113116
Raises:
114117
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -161,7 +164,7 @@ def __init__(
161164
scopes=scopes,
162165
quota_project_id=quota_project_id,
163166
client_info=client_info,
164-
always_use_jwt_access=True,
167+
always_use_jwt_access=always_use_jwt_access,
165168
)
166169

167170
if not self._grpc_channel:

google/cloud/resourcesettings_v1/services/resource_settings_service/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(
115115
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
116116
quota_project_id=None,
117117
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
118+
always_use_jwt_access: Optional[bool] = False,
118119
) -> None:
119120
"""Instantiate the transport.
120121
@@ -156,6 +157,8 @@ def __init__(
156157
API requests. If ``None``, then default info will be used.
157158
Generally, you only need to set this if you're developing
158159
your own client library.
160+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
161+
be used for service account credentials.
159162
160163
Raises:
161164
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -207,7 +210,7 @@ def __init__(
207210
scopes=scopes,
208211
quota_project_id=quota_project_id,
209212
client_info=client_info,
210-
always_use_jwt_access=True,
213+
always_use_jwt_access=always_use_jwt_access,
211214
)
212215

213216
if not self._grpc_channel:

tests/unit/gapic/resourcesettings_v1/test_resource_settings_service.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,25 @@ def test_resource_settings_service_client_service_account_always_use_jwt(client_
134134
) as use_jwt:
135135
creds = service_account.Credentials(None, None, None)
136136
client = client_class(credentials=creds)
137-
use_jwt.assert_called_with(True)
137+
use_jwt.assert_not_called()
138+
139+
140+
@pytest.mark.parametrize(
141+
"transport_class,transport_name",
142+
[
143+
(transports.ResourceSettingsServiceGrpcTransport, "grpc"),
144+
(transports.ResourceSettingsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
145+
],
146+
)
147+
def test_resource_settings_service_client_service_account_always_use_jwt_true(
148+
transport_class, transport_name
149+
):
150+
with mock.patch.object(
151+
service_account.Credentials, "with_always_use_jwt_access", create=True
152+
) as use_jwt:
153+
creds = service_account.Credentials(None, None, None)
154+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
155+
use_jwt.assert_called_once_with(True)
138156

139157

140158
@pytest.mark.parametrize(
@@ -1503,7 +1521,7 @@ def test_resource_settings_service_grpc_transport_client_cert_source_for_mtls(
15031521
"squid.clam.whelk:443",
15041522
credentials=cred,
15051523
credentials_file=None,
1506-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1524+
scopes=None,
15071525
ssl_credentials=mock_ssl_channel_creds,
15081526
quota_project_id=None,
15091527
options=[
@@ -1612,7 +1630,7 @@ def test_resource_settings_service_transport_channel_mtls_with_client_cert_sourc
16121630
"mtls.squid.clam.whelk:443",
16131631
credentials=cred,
16141632
credentials_file=None,
1615-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1633+
scopes=None,
16161634
ssl_credentials=mock_ssl_cred,
16171635
quota_project_id=None,
16181636
options=[
@@ -1659,7 +1677,7 @@ def test_resource_settings_service_transport_channel_mtls_with_adc(transport_cla
16591677
"mtls.squid.clam.whelk:443",
16601678
credentials=mock_cred,
16611679
credentials_file=None,
1662-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1680+
scopes=None,
16631681
ssl_credentials=mock_ssl_cred,
16641682
quota_project_id=None,
16651683
options=[

0 commit comments

Comments
 (0)