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

Commit 98d8b86

Browse files
fix: disable always_use_jwt_access (#66)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 0b497e4 commit 98d8b86

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(
100100
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
101101

102102
# Save the scopes.
103-
self._scopes = scopes or self.AUTH_SCOPES
103+
self._scopes = scopes
104104

105105
# If no credentials are provided, then determine the appropriate
106106
# defaults.

google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6666
quota_project_id: Optional[str] = None,
6767
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
68+
always_use_jwt_access: Optional[bool] = False,
6869
) -> None:
6970
"""Instantiate the transport.
7071
@@ -105,6 +106,8 @@ def __init__(
105106
API requests. If ``None``, then default info will be used.
106107
Generally, you only need to set this if you're developing
107108
your own client library.
109+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
110+
be used for service account credentials.
108111
109112
Raises:
110113
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -157,7 +160,7 @@ def __init__(
157160
scopes=scopes,
158161
quota_project_id=quota_project_id,
159162
client_info=client_info,
160-
always_use_jwt_access=True,
163+
always_use_jwt_access=always_use_jwt_access,
161164
)
162165

163166
if not self._grpc_channel:

google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py

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

140158

141159
@pytest.mark.parametrize(
@@ -2743,7 +2761,7 @@ def test_transcoder_service_grpc_transport_client_cert_source_for_mtls(transport
27432761
"squid.clam.whelk:443",
27442762
credentials=cred,
27452763
credentials_file=None,
2746-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2764+
scopes=None,
27472765
ssl_credentials=mock_ssl_channel_creds,
27482766
quota_project_id=None,
27492767
options=[
@@ -2852,7 +2870,7 @@ def test_transcoder_service_transport_channel_mtls_with_client_cert_source(
28522870
"mtls.squid.clam.whelk:443",
28532871
credentials=cred,
28542872
credentials_file=None,
2855-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2873+
scopes=None,
28562874
ssl_credentials=mock_ssl_cred,
28572875
quota_project_id=None,
28582876
options=[
@@ -2899,7 +2917,7 @@ def test_transcoder_service_transport_channel_mtls_with_adc(transport_class):
28992917
"mtls.squid.clam.whelk:443",
29002918
credentials=mock_cred,
29012919
credentials_file=None,
2902-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2920+
scopes=None,
29032921
ssl_credentials=mock_ssl_cred,
29042922
quota_project_id=None,
29052923
options=[

0 commit comments

Comments
 (0)