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

Commit 2085463

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

File tree

16 files changed

+124
-28
lines changed

16 files changed

+124
-28
lines changed

google/cloud/workflows/executions_v1/services/executions/transports/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__(
9696
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
9797

9898
# Save the scopes.
99-
self._scopes = scopes or self.AUTH_SCOPES
99+
self._scopes = scopes
100100

101101
# If no credentials are provided, then determine the appropriate
102102
# defaults.

google/cloud/workflows/executions_v1/services/executions/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
5959
quota_project_id: Optional[str] = None,
6060
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
61+
always_use_jwt_access: Optional[bool] = False,
6162
) -> None:
6263
"""Instantiate the transport.
6364
@@ -98,6 +99,8 @@ def __init__(
9899
API requests. If ``None``, then default info will be used.
99100
Generally, you only need to set this if you're developing
100101
your own client library.
102+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
103+
be used for service account credentials.
101104
102105
Raises:
103106
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -150,7 +153,7 @@ def __init__(
150153
scopes=scopes,
151154
quota_project_id=quota_project_id,
152155
client_info=client_info,
153-
always_use_jwt_access=True,
156+
always_use_jwt_access=always_use_jwt_access,
154157
)
155158

156159
if not self._grpc_channel:

google/cloud/workflows/executions_v1/services/executions/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def __init__(
104104
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
105105
quota_project_id=None,
106106
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
107+
always_use_jwt_access: Optional[bool] = False,
107108
) -> None:
108109
"""Instantiate the transport.
109110
@@ -145,6 +146,8 @@ def __init__(
145146
API requests. If ``None``, then default info will be used.
146147
Generally, you only need to set this if you're developing
147148
your own client library.
149+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
150+
be used for service account credentials.
148151
149152
Raises:
150153
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -196,7 +199,7 @@ def __init__(
196199
scopes=scopes,
197200
quota_project_id=quota_project_id,
198201
client_info=client_info,
199-
always_use_jwt_access=True,
202+
always_use_jwt_access=always_use_jwt_access,
200203
)
201204

202205
if not self._grpc_channel:

google/cloud/workflows/executions_v1beta/services/executions/transports/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__(
9696
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
9797

9898
# Save the scopes.
99-
self._scopes = scopes or self.AUTH_SCOPES
99+
self._scopes = scopes
100100

101101
# If no credentials are provided, then determine the appropriate
102102
# defaults.

google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6060
quota_project_id: Optional[str] = None,
6161
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
62+
always_use_jwt_access: Optional[bool] = False,
6263
) -> None:
6364
"""Instantiate the transport.
6465
@@ -99,6 +100,8 @@ def __init__(
99100
API requests. If ``None``, then default info will be used.
100101
Generally, you only need to set this if you're developing
101102
your own client library.
103+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
104+
be used for service account credentials.
102105
103106
Raises:
104107
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -151,7 +154,7 @@ def __init__(
151154
scopes=scopes,
152155
quota_project_id=quota_project_id,
153156
client_info=client_info,
154-
always_use_jwt_access=True,
157+
always_use_jwt_access=always_use_jwt_access,
155158
)
156159

157160
if not self._grpc_channel:

google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(
105105
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
106106
quota_project_id=None,
107107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
108+
always_use_jwt_access: Optional[bool] = False,
108109
) -> None:
109110
"""Instantiate the transport.
110111
@@ -146,6 +147,8 @@ def __init__(
146147
API requests. If ``None``, then default info will be used.
147148
Generally, you only need to set this if you're developing
148149
your own client library.
150+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
151+
be used for service account credentials.
149152
150153
Raises:
151154
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -197,7 +200,7 @@ def __init__(
197200
scopes=scopes,
198201
quota_project_id=quota_project_id,
199202
client_info=client_info,
200-
always_use_jwt_access=True,
203+
always_use_jwt_access=always_use_jwt_access,
201204
)
202205

203206
if not self._grpc_channel:

google/cloud/workflows_v1/services/workflows/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/workflows_v1/services/workflows/transports/grpc.py

+4-1
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
@@ -154,7 +157,7 @@ def __init__(
154157
scopes=scopes,
155158
quota_project_id=quota_project_id,
156159
client_info=client_info,
157-
always_use_jwt_access=True,
160+
always_use_jwt_access=always_use_jwt_access,
158161
)
159162

160163
if not self._grpc_channel:

google/cloud/workflows_v1/services/workflows/transports/grpc_asyncio.py

+4-1
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
@@ -200,7 +203,7 @@ def __init__(
200203
scopes=scopes,
201204
quota_project_id=quota_project_id,
202205
client_info=client_info,
203-
always_use_jwt_access=True,
206+
always_use_jwt_access=always_use_jwt_access,
204207
)
205208

206209
if not self._grpc_channel:

google/cloud/workflows_v1beta/services/workflows/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/workflows_v1beta/services/workflows/transports/grpc.py

+4-1
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
@@ -154,7 +157,7 @@ def __init__(
154157
scopes=scopes,
155158
quota_project_id=quota_project_id,
156159
client_info=client_info,
157-
always_use_jwt_access=True,
160+
always_use_jwt_access=always_use_jwt_access,
158161
)
159162

160163
if not self._grpc_channel:

google/cloud/workflows_v1beta/services/workflows/transports/grpc_asyncio.py

+4-1
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
@@ -200,7 +203,7 @@ def __init__(
200203
scopes=scopes,
201204
quota_project_id=quota_project_id,
202205
client_info=client_info,
203-
always_use_jwt_access=True,
206+
always_use_jwt_access=always_use_jwt_access,
204207
)
205208

206209
if not self._grpc_channel:

tests/unit/gapic/executions_v1/test_executions.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,25 @@ def test_executions_client_service_account_always_use_jwt(client_class):
123123
) as use_jwt:
124124
creds = service_account.Credentials(None, None, None)
125125
client = client_class(credentials=creds)
126-
use_jwt.assert_called_with(True)
126+
use_jwt.assert_not_called()
127+
128+
129+
@pytest.mark.parametrize(
130+
"transport_class,transport_name",
131+
[
132+
(transports.ExecutionsGrpcTransport, "grpc"),
133+
(transports.ExecutionsGrpcAsyncIOTransport, "grpc_asyncio"),
134+
],
135+
)
136+
def test_executions_client_service_account_always_use_jwt_true(
137+
transport_class, transport_name
138+
):
139+
with mock.patch.object(
140+
service_account.Credentials, "with_always_use_jwt_access", create=True
141+
) as use_jwt:
142+
creds = service_account.Credentials(None, None, None)
143+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
144+
use_jwt.assert_called_once_with(True)
127145

128146

129147
@pytest.mark.parametrize("client_class", [ExecutionsClient, ExecutionsAsyncClient,])
@@ -1723,7 +1741,7 @@ def test_executions_grpc_transport_client_cert_source_for_mtls(transport_class):
17231741
"squid.clam.whelk:443",
17241742
credentials=cred,
17251743
credentials_file=None,
1726-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1744+
scopes=None,
17271745
ssl_credentials=mock_ssl_channel_creds,
17281746
quota_project_id=None,
17291747
options=[
@@ -1827,7 +1845,7 @@ def test_executions_transport_channel_mtls_with_client_cert_source(transport_cla
18271845
"mtls.squid.clam.whelk:443",
18281846
credentials=cred,
18291847
credentials_file=None,
1830-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1848+
scopes=None,
18311849
ssl_credentials=mock_ssl_cred,
18321850
quota_project_id=None,
18331851
options=[
@@ -1871,7 +1889,7 @@ def test_executions_transport_channel_mtls_with_adc(transport_class):
18711889
"mtls.squid.clam.whelk:443",
18721890
credentials=mock_cred,
18731891
credentials_file=None,
1874-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1892+
scopes=None,
18751893
ssl_credentials=mock_ssl_cred,
18761894
quota_project_id=None,
18771895
options=[

tests/unit/gapic/executions_v1beta/test_executions.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,25 @@ def test_executions_client_service_account_always_use_jwt(client_class):
125125
) as use_jwt:
126126
creds = service_account.Credentials(None, None, None)
127127
client = client_class(credentials=creds)
128-
use_jwt.assert_called_with(True)
128+
use_jwt.assert_not_called()
129+
130+
131+
@pytest.mark.parametrize(
132+
"transport_class,transport_name",
133+
[
134+
(transports.ExecutionsGrpcTransport, "grpc"),
135+
(transports.ExecutionsGrpcAsyncIOTransport, "grpc_asyncio"),
136+
],
137+
)
138+
def test_executions_client_service_account_always_use_jwt_true(
139+
transport_class, transport_name
140+
):
141+
with mock.patch.object(
142+
service_account.Credentials, "with_always_use_jwt_access", create=True
143+
) as use_jwt:
144+
creds = service_account.Credentials(None, None, None)
145+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
146+
use_jwt.assert_called_once_with(True)
129147

130148

131149
@pytest.mark.parametrize("client_class", [ExecutionsClient, ExecutionsAsyncClient,])
@@ -1725,7 +1743,7 @@ def test_executions_grpc_transport_client_cert_source_for_mtls(transport_class):
17251743
"squid.clam.whelk:443",
17261744
credentials=cred,
17271745
credentials_file=None,
1728-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1746+
scopes=None,
17291747
ssl_credentials=mock_ssl_channel_creds,
17301748
quota_project_id=None,
17311749
options=[
@@ -1829,7 +1847,7 @@ def test_executions_transport_channel_mtls_with_client_cert_source(transport_cla
18291847
"mtls.squid.clam.whelk:443",
18301848
credentials=cred,
18311849
credentials_file=None,
1832-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1850+
scopes=None,
18331851
ssl_credentials=mock_ssl_cred,
18341852
quota_project_id=None,
18351853
options=[
@@ -1873,7 +1891,7 @@ def test_executions_transport_channel_mtls_with_adc(transport_class):
18731891
"mtls.squid.clam.whelk:443",
18741892
credentials=mock_cred,
18751893
credentials_file=None,
1876-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1894+
scopes=None,
18771895
ssl_credentials=mock_ssl_cred,
18781896
quota_project_id=None,
18791897
options=[

0 commit comments

Comments
 (0)