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

Commit 7768ae1

Browse files
fix: disable always_use_jwt_access (#151)
* chore: use gapic-generator-python 0.50.3 fix: disable always_use_jwt_access 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 578fd2e commit 7768ae1

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/devtools/containeranalysis_v1/services/container_analysis/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/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def __init__(
7373
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7474
quota_project_id: Optional[str] = None,
7575
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
76+
always_use_jwt_access: Optional[bool] = False,
7677
) -> None:
7778
"""Instantiate the transport.
7879
@@ -113,6 +114,8 @@ def __init__(
113114
API requests. If ``None``, then default info will be used.
114115
Generally, you only need to set this if you're developing
115116
your own client library.
117+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
118+
be used for service account credentials.
116119
117120
Raises:
118121
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -165,7 +168,7 @@ def __init__(
165168
scopes=scopes,
166169
quota_project_id=quota_project_id,
167170
client_info=client_info,
168-
always_use_jwt_access=True,
171+
always_use_jwt_access=always_use_jwt_access,
169172
)
170173

171174
if not self._grpc_channel:

google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def __init__(
119119
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
120120
quota_project_id=None,
121121
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
122+
always_use_jwt_access: Optional[bool] = False,
122123
) -> None:
123124
"""Instantiate the transport.
124125
@@ -160,6 +161,8 @@ def __init__(
160161
API requests. If ``None``, then default info will be used.
161162
Generally, you only need to set this if you're developing
162163
your own client library.
164+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
165+
be used for service account credentials.
163166
164167
Raises:
165168
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -211,7 +214,7 @@ def __init__(
211214
scopes=scopes,
212215
quota_project_id=quota_project_id,
213216
client_info=client_info,
214-
always_use_jwt_access=True,
217+
always_use_jwt_access=always_use_jwt_access,
215218
)
216219

217220
if not self._grpc_channel:

tests/unit/gapic/containeranalysis_v1/test_container_analysis.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,25 @@ def test_container_analysis_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.ContainerAnalysisGrpcTransport, "grpc"),
147+
(transports.ContainerAnalysisGrpcAsyncIOTransport, "grpc_asyncio"),
148+
],
149+
)
150+
def test_container_analysis_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(
@@ -1677,7 +1695,7 @@ def test_container_analysis_grpc_transport_client_cert_source_for_mtls(transport
16771695
"squid.clam.whelk:443",
16781696
credentials=cred,
16791697
credentials_file=None,
1680-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1698+
scopes=None,
16811699
ssl_credentials=mock_ssl_channel_creds,
16821700
quota_project_id=None,
16831701
options=[
@@ -1786,7 +1804,7 @@ def test_container_analysis_transport_channel_mtls_with_client_cert_source(
17861804
"mtls.squid.clam.whelk:443",
17871805
credentials=cred,
17881806
credentials_file=None,
1789-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1807+
scopes=None,
17901808
ssl_credentials=mock_ssl_cred,
17911809
quota_project_id=None,
17921810
options=[
@@ -1833,7 +1851,7 @@ def test_container_analysis_transport_channel_mtls_with_adc(transport_class):
18331851
"mtls.squid.clam.whelk:443",
18341852
credentials=mock_cred,
18351853
credentials_file=None,
1836-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1854+
scopes=None,
18371855
ssl_credentials=mock_ssl_cred,
18381856
quota_project_id=None,
18391857
options=[

0 commit comments

Comments
 (0)