Thanks to visit codestin.com
Credit goes to github.com

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

Commit d4db355

Browse files
fix: disable always_use_jwt_access (#13)
* chore: use gapic-generator-python 0.50.3 Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ee9c7d2 commit d4db355

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6363
quota_project_id: Optional[str] = None,
6464
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
65+
always_use_jwt_access: Optional[bool] = False,
6566
) -> None:
6667
"""Instantiate the transport.
6768
@@ -102,6 +103,8 @@ def __init__(
102103
API requests. If ``None``, then default info will be used.
103104
Generally, you only need to set this if you're developing
104105
your own client library.
106+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
107+
be used for service account credentials.
105108
106109
Raises:
107110
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,7 +158,7 @@ def __init__(
155158
scopes=scopes,
156159
quota_project_id=quota_project_id,
157160
client_info=client_info,
158-
always_use_jwt_access=True,
161+
always_use_jwt_access=always_use_jwt_access,
159162
)
160163

161164
if not self._grpc_channel:

google/cloud/eventarc_v1/services/eventarc/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def __init__(
108108
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
109109
quota_project_id=None,
110110
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
111+
always_use_jwt_access: Optional[bool] = False,
111112
) -> None:
112113
"""Instantiate the transport.
113114
@@ -149,6 +150,8 @@ def __init__(
149150
API requests. If ``None``, then default info will be used.
150151
Generally, you only need to set this if you're developing
151152
your own client library.
153+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
154+
be used for service account credentials.
152155
153156
Raises:
154157
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,7 +204,7 @@ def __init__(
201204
scopes=scopes,
202205
quota_project_id=quota_project_id,
203206
client_info=client_info,
204-
always_use_jwt_access=True,
207+
always_use_jwt_access=always_use_jwt_access,
205208
)
206209

207210
if not self._grpc_channel:

tests/unit/gapic/eventarc_v1/test_eventarc.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,25 @@ def test_eventarc_client_service_account_always_use_jwt(client_class):
126126
) as use_jwt:
127127
creds = service_account.Credentials(None, None, None)
128128
client = client_class(credentials=creds)
129-
use_jwt.assert_called_with(True)
129+
use_jwt.assert_not_called()
130+
131+
132+
@pytest.mark.parametrize(
133+
"transport_class,transport_name",
134+
[
135+
(transports.EventarcGrpcTransport, "grpc"),
136+
(transports.EventarcGrpcAsyncIOTransport, "grpc_asyncio"),
137+
],
138+
)
139+
def test_eventarc_client_service_account_always_use_jwt_true(
140+
transport_class, transport_name
141+
):
142+
with mock.patch.object(
143+
service_account.Credentials, "with_always_use_jwt_access", create=True
144+
) as use_jwt:
145+
creds = service_account.Credentials(None, None, None)
146+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
147+
use_jwt.assert_called_once_with(True)
130148

131149

132150
@pytest.mark.parametrize("client_class", [EventarcClient, EventarcAsyncClient,])
@@ -1881,7 +1899,7 @@ def test_eventarc_grpc_transport_client_cert_source_for_mtls(transport_class):
18811899
"squid.clam.whelk:443",
18821900
credentials=cred,
18831901
credentials_file=None,
1884-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1902+
scopes=None,
18851903
ssl_credentials=mock_ssl_channel_creds,
18861904
quota_project_id=None,
18871905
options=[
@@ -1985,7 +2003,7 @@ def test_eventarc_transport_channel_mtls_with_client_cert_source(transport_class
19852003
"mtls.squid.clam.whelk:443",
19862004
credentials=cred,
19872005
credentials_file=None,
1988-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2006+
scopes=None,
19892007
ssl_credentials=mock_ssl_cred,
19902008
quota_project_id=None,
19912009
options=[
@@ -2029,7 +2047,7 @@ def test_eventarc_transport_channel_mtls_with_adc(transport_class):
20292047
"mtls.squid.clam.whelk:443",
20302048
credentials=mock_cred,
20312049
credentials_file=None,
2032-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2050+
scopes=None,
20332051
ssl_credentials=mock_ssl_cred,
20342052
quota_project_id=None,
20352053
options=[

0 commit comments

Comments
 (0)