Content-Length: 752955 | pFad | https://www.github.com/googleapis/python-scheduler/commit/c8dd497c56f475c63c05c2ba5708067cc03c4173

218 fix: disable always_use_jwt_access (#106) · googleapis/python-scheduler@c8dd497 · GitHub
Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit c8dd497

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

File tree

8 files changed

+62
-14
lines changed

8 files changed

+62
-14
lines changed

google/cloud/scheduler_v1/services/cloud_scheduler/transports/base.py

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

101101
# Save the scopes.
102-
self._scopes = scopes or self.AUTH_SCOPES
102+
self._scopes = scopes
103103

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

google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6262
quota_project_id: Optional[str] = None,
6363
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
64+
always_use_jwt_access: Optional[bool] = False,
6465
) -> None:
6566
"""Instantiate the transport.
6667
@@ -101,6 +102,8 @@ def __init__(
101102
API requests. If ``None``, then default info will be used.
102103
Generally, you only need to set this if you're developing
103104
your own client library.
105+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
106+
be used for service account credentials.
104107
105108
Raises:
106109
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -153,7 +156,7 @@ def __init__(
153156
scopes=scopes,
154157
quota_project_id=quota_project_id,
155158
client_info=client_info,
156-
always_use_jwt_access=True,
159+
always_use_jwt_access=always_use_jwt_access,
157160
)
158161

159162
if not self._grpc_channel:

google/cloud/scheduler_v1/services/cloud_scheduler/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def __init__(
107107
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
108108
quota_project_id=None,
109109
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
110+
always_use_jwt_access: Optional[bool] = False,
110111
) -> None:
111112
"""Instantiate the transport.
112113
@@ -148,6 +149,8 @@ def __init__(
148149
API requests. If ``None``, then default info will be used.
149150
Generally, you only need to set this if you're developing
150151
your own client library.
152+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
153+
be used for service account credentials.
151154
152155
Raises:
153156
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -199,7 +202,7 @@ def __init__(
199202
scopes=scopes,
200203
quota_project_id=quota_project_id,
201204
client_info=client_info,
202-
always_use_jwt_access=True,
205+
always_use_jwt_access=always_use_jwt_access,
203206
)
204207

205208
if not self._grpc_channel:

google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/base.py

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

101101
# Save the scopes.
102-
self._scopes = scopes or self.AUTH_SCOPES
102+
self._scopes = scopes
103103

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

google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6262
quota_project_id: Optional[str] = None,
6363
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
64+
always_use_jwt_access: Optional[bool] = False,
6465
) -> None:
6566
"""Instantiate the transport.
6667
@@ -101,6 +102,8 @@ def __init__(
101102
API requests. If ``None``, then default info will be used.
102103
Generally, you only need to set this if you're developing
103104
your own client library.
105+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
106+
be used for service account credentials.
104107
105108
Raises:
106109
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -153,7 +156,7 @@ def __init__(
153156
scopes=scopes,
154157
quota_project_id=quota_project_id,
155158
client_info=client_info,
156-
always_use_jwt_access=True,
159+
always_use_jwt_access=always_use_jwt_access,
157160
)
158161

159162
if not self._grpc_channel:

google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def __init__(
107107
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
108108
quota_project_id=None,
109109
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
110+
always_use_jwt_access: Optional[bool] = False,
110111
) -> None:
111112
"""Instantiate the transport.
112113
@@ -148,6 +149,8 @@ def __init__(
148149
API requests. If ``None``, then default info will be used.
149150
Generally, you only need to set this if you're developing
150151
your own client library.
152+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
153+
be used for service account credentials.
151154
152155
Raises:
153156
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -199,7 +202,7 @@ def __init__(
199202
scopes=scopes,
200203
quota_project_id=quota_project_id,
201204
client_info=client_info,
202-
always_use_jwt_access=True,
205+
always_use_jwt_access=always_use_jwt_access,
203206
)
204207

205208
if not self._grpc_channel:

tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,25 @@ def test_cloud_scheduler_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.CloudSchedulerGrpcTransport, "grpc"),
145+
(transports.CloudSchedulerGrpcAsyncIOTransport, "grpc_asyncio"),
146+
],
147+
)
148+
def test_cloud_scheduler_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(
@@ -2597,7 +2615,7 @@ def test_cloud_scheduler_grpc_transport_client_cert_source_for_mtls(transport_cl
25972615
"squid.clam.whelk:443",
25982616
credentials=cred,
25992617
credentials_file=None,
2600-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2618+
scopes=None,
26012619
ssl_credentials=mock_ssl_channel_creds,
26022620
quota_project_id=None,
26032621
options=[
@@ -2706,7 +2724,7 @@ def test_cloud_scheduler_transport_channel_mtls_with_client_cert_source(
27062724
"mtls.squid.clam.whelk:443",
27072725
credentials=cred,
27082726
credentials_file=None,
2709-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2727+
scopes=None,
27102728
ssl_credentials=mock_ssl_cred,
27112729
quota_project_id=None,
27122730
options=[
@@ -2753,7 +2771,7 @@ def test_cloud_scheduler_transport_channel_mtls_with_adc(transport_class):
27532771
"mtls.squid.clam.whelk:443",
27542772
credentials=mock_cred,
27552773
credentials_file=None,
2756-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2774+
scopes=None,
27572775
ssl_credentials=mock_ssl_cred,
27582776
quota_project_id=None,
27592777
options=[

tests/unit/gapic/scheduler_v1beta1/test_cloud_scheduler.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,25 @@ def test_cloud_scheduler_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.CloudSchedulerGrpcTransport, "grpc"),
147+
(transports.CloudSchedulerGrpcAsyncIOTransport, "grpc_asyncio"),
148+
],
149+
)
150+
def test_cloud_scheduler_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(
@@ -2599,7 +2617,7 @@ def test_cloud_scheduler_grpc_transport_client_cert_source_for_mtls(transport_cl
25992617
"squid.clam.whelk:443",
26002618
credentials=cred,
26012619
credentials_file=None,
2602-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2620+
scopes=None,
26032621
ssl_credentials=mock_ssl_channel_creds,
26042622
quota_project_id=None,
26052623
options=[
@@ -2708,7 +2726,7 @@ def test_cloud_scheduler_transport_channel_mtls_with_client_cert_source(
27082726
"mtls.squid.clam.whelk:443",
27092727
credentials=cred,
27102728
credentials_file=None,
2711-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2729+
scopes=None,
27122730
ssl_credentials=mock_ssl_cred,
27132731
quota_project_id=None,
27142732
options=[
@@ -2755,7 +2773,7 @@ def test_cloud_scheduler_transport_channel_mtls_with_adc(transport_class):
27552773
"mtls.squid.clam.whelk:443",
27562774
credentials=mock_cred,
27572775
credentials_file=None,
2758-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2776+
scopes=None,
27592777
ssl_credentials=mock_ssl_cred,
27602778
quota_project_id=None,
27612779
options=[

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.github.com/googleapis/python-scheduler/commit/c8dd497c56f475c63c05c2ba5708067cc03c4173

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy