Skip to content

Commit a95e401

Browse files
fix: disable always_use_jwt_access (#342)
* chore: use gapic-generator-python 0.50.3 Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: googleapis/googleapis-gen@7b1e2c3 * 🦉 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 9e943db commit a95e401

File tree

12 files changed

+93
-72
lines changed

12 files changed

+93
-72
lines changed

google/cloud/logging_v2/services/config_service_v2/transports/base.py

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

104104
# Save the scopes.
105-
self._scopes = scopes or self.AUTH_SCOPES
105+
self._scopes = scopes
106106

107107
# If no credentials are provided, then determine the appropriate
108108
# defaults.

google/cloud/logging_v2/services/config_service_v2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
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/logging_v2/services/config_service_v2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
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/logging_v2/services/logging_service_v2/transports/base.py

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

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
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/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
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/logging_v2/services/metrics_service_v2/transports/base.py

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

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
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/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
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:

tests/unit/gapic/logging_v2/test_config_service_v2.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,25 @@ def test_config_service_v2_client_service_account_always_use_jwt(client_class):
131131
) as use_jwt:
132132
creds = service_account.Credentials(None, None, None)
133133
client = client_class(credentials=creds)
134-
use_jwt.assert_called_with(True)
134+
use_jwt.assert_not_called()
135+
136+
137+
@pytest.mark.parametrize(
138+
"transport_class,transport_name",
139+
[
140+
(transports.ConfigServiceV2GrpcTransport, "grpc"),
141+
(transports.ConfigServiceV2GrpcAsyncIOTransport, "grpc_asyncio"),
142+
],
143+
)
144+
def test_config_service_v2_client_service_account_always_use_jwt_true(
145+
transport_class, transport_name
146+
):
147+
with mock.patch.object(
148+
service_account.Credentials, "with_always_use_jwt_access", create=True
149+
) as use_jwt:
150+
creds = service_account.Credentials(None, None, None)
151+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
152+
use_jwt.assert_called_once_with(True)
135153

136154

137155
@pytest.mark.parametrize(
@@ -5625,12 +5643,7 @@ def test_config_service_v2_grpc_transport_client_cert_source_for_mtls(transport_
56255643
"squid.clam.whelk:443",
56265644
credentials=cred,
56275645
credentials_file=None,
5628-
scopes=(
5629-
"https://www.googleapis.com/auth/cloud-platform",
5630-
"https://www.googleapis.com/auth/cloud-platform.read-only",
5631-
"https://www.googleapis.com/auth/logging.admin",
5632-
"https://www.googleapis.com/auth/logging.read",
5633-
),
5646+
scopes=None,
56345647
ssl_credentials=mock_ssl_channel_creds,
56355648
quota_project_id=None,
56365649
options=[
@@ -5739,12 +5752,7 @@ def test_config_service_v2_transport_channel_mtls_with_client_cert_source(
57395752
"mtls.squid.clam.whelk:443",
57405753
credentials=cred,
57415754
credentials_file=None,
5742-
scopes=(
5743-
"https://www.googleapis.com/auth/cloud-platform",
5744-
"https://www.googleapis.com/auth/cloud-platform.read-only",
5745-
"https://www.googleapis.com/auth/logging.admin",
5746-
"https://www.googleapis.com/auth/logging.read",
5747-
),
5755+
scopes=None,
57485756
ssl_credentials=mock_ssl_cred,
57495757
quota_project_id=None,
57505758
options=[
@@ -5791,12 +5799,7 @@ def test_config_service_v2_transport_channel_mtls_with_adc(transport_class):
57915799
"mtls.squid.clam.whelk:443",
57925800
credentials=mock_cred,
57935801
credentials_file=None,
5794-
scopes=(
5795-
"https://www.googleapis.com/auth/cloud-platform",
5796-
"https://www.googleapis.com/auth/cloud-platform.read-only",
5797-
"https://www.googleapis.com/auth/logging.admin",
5798-
"https://www.googleapis.com/auth/logging.read",
5799-
),
5802+
scopes=None,
58005803
ssl_credentials=mock_ssl_cred,
58015804
quota_project_id=None,
58025805
options=[

0 commit comments

Comments
 (0)