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

Commit 9a14561

Browse files
fix: disable always_use_jwt_access (#5)
* 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 339cb28 commit 9a14561

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎google/cloud/network_security_v1beta1/services/network_security/transports/base.py‎

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

113113
# Save the scopes.
114-
self._scopes = scopes or self.AUTH_SCOPES
114+
self._scopes = scopes
115115

116116
# If no credentials are provided, then determine the appropriate
117117
# defaults.

‎google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(
6868
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6969
quota_project_id: Optional[str] = None,
7070
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
71+
always_use_jwt_access: Optional[bool] = False,
7172
) -> None:
7273
"""Instantiate the transport.
7374
@@ -108,6 +109,8 @@ def __init__(
108109
API requests. If ``None``, then default info will be used.
109110
Generally, you only need to set this if you're developing
110111
your own client library.
112+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
113+
be used for service account credentials.
111114
112115
Raises:
113116
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -161,7 +164,7 @@ def __init__(
161164
scopes=scopes,
162165
quota_project_id=quota_project_id,
163166
client_info=client_info,
164-
always_use_jwt_access=True,
167+
always_use_jwt_access=always_use_jwt_access,
165168
)
166169

167170
if not self._grpc_channel:

‎google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def __init__(
114114
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
115115
quota_project_id=None,
116116
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
117+
always_use_jwt_access: Optional[bool] = False,
117118
) -> None:
118119
"""Instantiate the transport.
119120
@@ -155,6 +156,8 @@ def __init__(
155156
API requests. If ``None``, then default info will be used.
156157
Generally, you only need to set this if you're developing
157158
your own client library.
159+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
160+
be used for service account credentials.
158161
159162
Raises:
160163
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -207,7 +210,7 @@ def __init__(
207210
scopes=scopes,
208211
quota_project_id=quota_project_id,
209212
client_info=client_info,
210-
always_use_jwt_access=True,
213+
always_use_jwt_access=always_use_jwt_access,
211214
)
212215

213216
if not self._grpc_channel:

‎tests/unit/gapic/network_security_v1beta1/test_network_security.py‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,25 @@ def test_network_security_client_service_account_always_use_jwt(client_class):
150150
) as use_jwt:
151151
creds = service_account.Credentials(None, None, None)
152152
client = client_class(credentials=creds)
153-
use_jwt.assert_called_with(True)
153+
use_jwt.assert_not_called()
154+
155+
156+
@pytest.mark.parametrize(
157+
"transport_class,transport_name",
158+
[
159+
(transports.NetworkSecurityGrpcTransport, "grpc"),
160+
(transports.NetworkSecurityGrpcAsyncIOTransport, "grpc_asyncio"),
161+
],
162+
)
163+
def test_network_security_client_service_account_always_use_jwt_true(
164+
transport_class, transport_name
165+
):
166+
with mock.patch.object(
167+
service_account.Credentials, "with_always_use_jwt_access", create=True
168+
) as use_jwt:
169+
creds = service_account.Credentials(None, None, None)
170+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
171+
use_jwt.assert_called_once_with(True)
154172

155173

156174
@pytest.mark.parametrize(
@@ -4772,7 +4790,7 @@ def test_network_security_grpc_transport_client_cert_source_for_mtls(transport_c
47724790
"squid.clam.whelk:443",
47734791
credentials=cred,
47744792
credentials_file=None,
4775-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4793+
scopes=None,
47764794
ssl_credentials=mock_ssl_channel_creds,
47774795
quota_project_id=None,
47784796
options=[
@@ -4881,7 +4899,7 @@ def test_network_security_transport_channel_mtls_with_client_cert_source(
48814899
"mtls.squid.clam.whelk:443",
48824900
credentials=cred,
48834901
credentials_file=None,
4884-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4902+
scopes=None,
48854903
ssl_credentials=mock_ssl_cred,
48864904
quota_project_id=None,
48874905
options=[
@@ -4928,7 +4946,7 @@ def test_network_security_transport_channel_mtls_with_adc(transport_class):
49284946
"mtls.squid.clam.whelk:443",
49294947
credentials=mock_cred,
49304948
credentials_file=None,
4931-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
4949+
scopes=None,
49324950
ssl_credentials=mock_ssl_cred,
49334951
quota_project_id=None,
49344952
options=[

0 commit comments

Comments
 (0)