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

Commit 3fb3edd

Browse files
fix: disable always_use_jwt_access (#79)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent b057abd commit 3fb3edd

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

google/cloud/mediatranslation_v1beta1/services/speech_translation_service/transports/base.py

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
5858
quota_project_id: Optional[str] = None,
5959
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
60+
always_use_jwt_access: Optional[bool] = False,
6061
) -> None:
6162
"""Instantiate the transport.
6263
@@ -97,6 +98,8 @@ def __init__(
9798
API requests. If ``None``, then default info will be used.
9899
Generally, you only need to set this if you're developing
99100
your own client library.
101+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
102+
be used for service account credentials.
100103
101104
Raises:
102105
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -149,7 +152,7 @@ def __init__(
149152
scopes=scopes,
150153
quota_project_id=quota_project_id,
151154
client_info=client_info,
152-
always_use_jwt_access=True,
155+
always_use_jwt_access=always_use_jwt_access,
153156
)
154157

155158
if not self._grpc_channel:

google/cloud/mediatranslation_v1beta1/services/speech_translation_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def __init__(
103103
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
104104
quota_project_id=None,
105105
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
106+
always_use_jwt_access: Optional[bool] = False,
106107
) -> None:
107108
"""Instantiate the transport.
108109
@@ -144,6 +145,8 @@ def __init__(
144145
API requests. If ``None``, then default info will be used.
145146
Generally, you only need to set this if you're developing
146147
your own client library.
148+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
149+
be used for service account credentials.
147150
148151
Raises:
149152
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -195,7 +198,7 @@ def __init__(
195198
scopes=scopes,
196199
quota_project_id=quota_project_id,
197200
client_info=client_info,
198-
always_use_jwt_access=True,
201+
always_use_jwt_access=always_use_jwt_access,
199202
)
200203

201204
if not self._grpc_channel:

tests/unit/gapic/mediatranslation_v1beta1/test_speech_translation_service.py

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

141159

142160
@pytest.mark.parametrize(
@@ -867,7 +885,7 @@ def test_speech_translation_service_grpc_transport_client_cert_source_for_mtls(
867885
"squid.clam.whelk:443",
868886
credentials=cred,
869887
credentials_file=None,
870-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
888+
scopes=None,
871889
ssl_credentials=mock_ssl_channel_creds,
872890
quota_project_id=None,
873891
options=[
@@ -976,7 +994,7 @@ def test_speech_translation_service_transport_channel_mtls_with_client_cert_sour
976994
"mtls.squid.clam.whelk:443",
977995
credentials=cred,
978996
credentials_file=None,
979-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
997+
scopes=None,
980998
ssl_credentials=mock_ssl_cred,
981999
quota_project_id=None,
9821000
options=[
@@ -1023,7 +1041,7 @@ def test_speech_translation_service_transport_channel_mtls_with_adc(transport_cl
10231041
"mtls.squid.clam.whelk:443",
10241042
credentials=mock_cred,
10251043
credentials_file=None,
1026-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1044+
scopes=None,
10271045
ssl_credentials=mock_ssl_cred,
10281046
quota_project_id=None,
10291047
options=[

0 commit comments

Comments
 (0)