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

Commit b840980

Browse files
fix: disable always_use_jwt_access (#52)
* 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 70a2535 commit b840980

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py

Lines changed: 1 addition & 1 deletion
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/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6868
quota_project_id: Optional[str] = None,
6969
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
70+
always_use_jwt_access: Optional[bool] = False,
7071
) -> None:
7172
"""Instantiate the transport.
7273
@@ -107,6 +108,8 @@ def __init__(
107108
API requests. If ``None``, then default info will be used.
108109
Generally, you only need to set this if you're developing
109110
your own client library.
111+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
112+
be used for service account credentials.
110113
111114
Raises:
112115
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -159,7 +162,7 @@ def __init__(
159162
scopes=scopes,
160163
quota_project_id=quota_project_id,
161164
client_info=client_info,
162-
always_use_jwt_access=True,
165+
always_use_jwt_access=always_use_jwt_access,
163166
)
164167

165168
if not self._grpc_channel:

google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(
113113
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
114114
quota_project_id=None,
115115
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
116+
always_use_jwt_access: Optional[bool] = False,
116117
) -> None:
117118
"""Instantiate the transport.
118119
@@ -154,6 +155,8 @@ def __init__(
154155
API requests. If ``None``, then default info will be used.
155156
Generally, you only need to set this if you're developing
156157
your own client library.
158+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
159+
be used for service account credentials.
157160
158161
Raises:
159162
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -205,7 +208,7 @@ def __init__(
205208
scopes=scopes,
206209
quota_project_id=quota_project_id,
207210
client_info=client_info,
208-
always_use_jwt_access=True,
211+
always_use_jwt_access=always_use_jwt_access,
209212
)
210213

211214
if not self._grpc_channel:

tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,28 @@ def test_binauthz_management_service_v1_beta1_client_service_account_always_use_
158158
) as use_jwt:
159159
creds = service_account.Credentials(None, None, None)
160160
client = client_class(credentials=creds)
161-
use_jwt.assert_called_with(True)
161+
use_jwt.assert_not_called()
162+
163+
164+
@pytest.mark.parametrize(
165+
"transport_class,transport_name",
166+
[
167+
(transports.BinauthzManagementServiceV1Beta1GrpcTransport, "grpc"),
168+
(
169+
transports.BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport,
170+
"grpc_asyncio",
171+
),
172+
],
173+
)
174+
def test_binauthz_management_service_v1_beta1_client_service_account_always_use_jwt_true(
175+
transport_class, transport_name
176+
):
177+
with mock.patch.object(
178+
service_account.Credentials, "with_always_use_jwt_access", create=True
179+
) as use_jwt:
180+
creds = service_account.Credentials(None, None, None)
181+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
182+
use_jwt.assert_called_once_with(True)
162183

163184

164185
@pytest.mark.parametrize(
@@ -2492,7 +2513,7 @@ def test_binauthz_management_service_v1_beta1_grpc_transport_client_cert_source_
24922513
"squid.clam.whelk:443",
24932514
credentials=cred,
24942515
credentials_file=None,
2495-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2516+
scopes=None,
24962517
ssl_credentials=mock_ssl_channel_creds,
24972518
quota_project_id=None,
24982519
options=[
@@ -2601,7 +2622,7 @@ def test_binauthz_management_service_v1_beta1_transport_channel_mtls_with_client
26012622
"mtls.squid.clam.whelk:443",
26022623
credentials=cred,
26032624
credentials_file=None,
2604-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2625+
scopes=None,
26052626
ssl_credentials=mock_ssl_cred,
26062627
quota_project_id=None,
26072628
options=[
@@ -2650,7 +2671,7 @@ def test_binauthz_management_service_v1_beta1_transport_channel_mtls_with_adc(
26502671
"mtls.squid.clam.whelk:443",
26512672
credentials=mock_cred,
26522673
credentials_file=None,
2653-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
2674+
scopes=None,
26542675
ssl_credentials=mock_ssl_cred,
26552676
quota_project_id=None,
26562677
options=[

0 commit comments

Comments
 (0)