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

Commit 47cdda9

Browse files
fix: disable always_use_jwt_access (#143)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 3650eb3 commit 47cdda9

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py

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

104104
# Save the scopes.
105-
self._scopes = scopes or self.AUTH_SCOPES
105+
self._scopes = scopes
106106

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

google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6868
quota_project_id: Optional[str] = None,
6969
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
70+
always_use_jwt_access: Optional[bool] = False,
7071
) -> None:
7172
"""Instantiate the transport.
7273
@@ -107,6 +108,8 @@ def __init__(
107108
API requests. If ``None``, then default info will be used.
108109
Generally, you only need to set this if you're developing
109110
your own client library.
111+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
112+
be used for service account credentials.
110113
111114
Raises:
112115
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -159,7 +162,7 @@ def __init__(
159162
scopes=scopes,
160163
quota_project_id=quota_project_id,
161164
client_info=client_info,
162-
always_use_jwt_access=True,
165+
always_use_jwt_access=always_use_jwt_access,
163166
)
164167

165168
if not self._grpc_channel:

google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(
113113
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
114114
quota_project_id=None,
115115
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
116+
always_use_jwt_access: Optional[bool] = False,
116117
) -> None:
117118
"""Instantiate the transport.
118119
@@ -154,6 +155,8 @@ def __init__(
154155
API requests. If ``None``, then default info will be used.
155156
Generally, you only need to set this if you're developing
156157
your own client library.
158+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
159+
be used for service account credentials.
157160
158161
Raises:
159162
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -205,7 +208,7 @@ def __init__(
205208
scopes=scopes,
206209
quota_project_id=quota_project_id,
207210
client_info=client_info,
208-
always_use_jwt_access=True,
211+
always_use_jwt_access=always_use_jwt_access,
209212
)
210213

211214
if not self._grpc_channel:

tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,25 @@ def test_secret_manager_service_client_service_account_always_use_jwt(client_cla
140140
) as use_jwt:
141141
creds = service_account.Credentials(None, None, None)
142142
client = client_class(credentials=creds)
143-
use_jwt.assert_called_with(True)
143+
use_jwt.assert_not_called()
144+
145+
146+
@pytest.mark.parametrize(
147+
"transport_class,transport_name",
148+
[
149+
(transports.SecretManagerServiceGrpcTransport, "grpc"),
150+
(transports.SecretManagerServiceGrpcAsyncIOTransport, "grpc_asyncio"),
151+
],
152+
)
153+
def test_secret_manager_service_client_service_account_always_use_jwt_true(
154+
transport_class, transport_name
155+
):
156+
with mock.patch.object(
157+
service_account.Credentials, "with_always_use_jwt_access", create=True
158+
) as use_jwt:
159+
creds = service_account.Credentials(None, None, None)
160+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
161+
use_jwt.assert_called_once_with(True)
144162

145163

146164
@pytest.mark.parametrize(
@@ -4263,7 +4281,7 @@ def test_secret_manager_service_grpc_transport_client_cert_source_for_mtls(
42634281
"squid.clam.whelk:443",
42644282
credentials=cred,
42654283
credentials_file=None,
4266-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4284+
scopes=None,
42674285
ssl_credentials=mock_ssl_channel_creds,
42684286
quota_project_id=None,
42694287
options=[
@@ -4372,7 +4390,7 @@ def test_secret_manager_service_transport_channel_mtls_with_client_cert_source(
43724390
"mtls.squid.clam.whelk:443",
43734391
credentials=cred,
43744392
credentials_file=None,
4375-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4393+
scopes=None,
43764394
ssl_credentials=mock_ssl_cred,
43774395
quota_project_id=None,
43784396
options=[
@@ -4419,7 +4437,7 @@ def test_secret_manager_service_transport_channel_mtls_with_adc(transport_class)
44194437
"mtls.squid.clam.whelk:443",
44204438
credentials=mock_cred,
44214439
credentials_file=None,
4422-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4440+
scopes=None,
44234441
ssl_credentials=mock_ssl_cred,
44244442
quota_project_id=None,
44254443
options=[

0 commit comments

Comments
 (0)