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

+1-1
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

+4-1
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

+4-1
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

+1-1
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

+4-1
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

+4-1
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

+1-1
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

+4-1
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

+4-1
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

+22-19
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=[

tests/unit/gapic/logging_v2/test_logging_service_v2.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,25 @@ def test_logging_service_v2_client_service_account_always_use_jwt(client_class):
138138
) as use_jwt:
139139
creds = service_account.Credentials(None, None, None)
140140
client = client_class(credentials=creds)
141-
use_jwt.assert_called_with(True)
141+
use_jwt.assert_not_called()
142+
143+
144+
@pytest.mark.parametrize(
145+
"transport_class,transport_name",
146+
[
147+
(transports.LoggingServiceV2GrpcTransport, "grpc"),
148+
(transports.LoggingServiceV2GrpcAsyncIOTransport, "grpc_asyncio"),
149+
],
150+
)
151+
def test_logging_service_v2_client_service_account_always_use_jwt_true(
152+
transport_class, transport_name
153+
):
154+
with mock.patch.object(
155+
service_account.Credentials, "with_always_use_jwt_access", create=True
156+
) as use_jwt:
157+
creds = service_account.Credentials(None, None, None)
158+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
159+
use_jwt.assert_called_once_with(True)
142160

143161

144162
@pytest.mark.parametrize(
@@ -2164,13 +2182,7 @@ def test_logging_service_v2_grpc_transport_client_cert_source_for_mtls(transport
21642182
"squid.clam.whelk:443",
21652183
credentials=cred,
21662184
credentials_file=None,
2167-
scopes=(
2168-
"https://www.googleapis.com/auth/cloud-platform",
2169-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2170-
"https://www.googleapis.com/auth/logging.admin",
2171-
"https://www.googleapis.com/auth/logging.read",
2172-
"https://www.googleapis.com/auth/logging.write",
2173-
),
2185+
scopes=None,
21742186
ssl_credentials=mock_ssl_channel_creds,
21752187
quota_project_id=None,
21762188
options=[
@@ -2279,13 +2291,7 @@ def test_logging_service_v2_transport_channel_mtls_with_client_cert_source(
22792291
"mtls.squid.clam.whelk:443",
22802292
credentials=cred,
22812293
credentials_file=None,
2282-
scopes=(
2283-
"https://www.googleapis.com/auth/cloud-platform",
2284-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2285-
"https://www.googleapis.com/auth/logging.admin",
2286-
"https://www.googleapis.com/auth/logging.read",
2287-
"https://www.googleapis.com/auth/logging.write",
2288-
),
2294+
scopes=None,
22892295
ssl_credentials=mock_ssl_cred,
22902296
quota_project_id=None,
22912297
options=[
@@ -2332,13 +2338,7 @@ def test_logging_service_v2_transport_channel_mtls_with_adc(transport_class):
23322338
"mtls.squid.clam.whelk:443",
23332339
credentials=mock_cred,
23342340
credentials_file=None,
2335-
scopes=(
2336-
"https://www.googleapis.com/auth/cloud-platform",
2337-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2338-
"https://www.googleapis.com/auth/logging.admin",
2339-
"https://www.googleapis.com/auth/logging.read",
2340-
"https://www.googleapis.com/auth/logging.write",
2341-
),
2341+
scopes=None,
23422342
ssl_credentials=mock_ssl_cred,
23432343
quota_project_id=None,
23442344
options=[

tests/unit/gapic/logging_v2/test_metrics_service_v2.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,25 @@ def test_metrics_service_v2_client_service_account_always_use_jwt(client_class):
136136
) as use_jwt:
137137
creds = service_account.Credentials(None, None, None)
138138
client = client_class(credentials=creds)
139-
use_jwt.assert_called_with(True)
139+
use_jwt.assert_not_called()
140+
141+
142+
@pytest.mark.parametrize(
143+
"transport_class,transport_name",
144+
[
145+
(transports.MetricsServiceV2GrpcTransport, "grpc"),
146+
(transports.MetricsServiceV2GrpcAsyncIOTransport, "grpc_asyncio"),
147+
],
148+
)
149+
def test_metrics_service_v2_client_service_account_always_use_jwt_true(
150+
transport_class, transport_name
151+
):
152+
with mock.patch.object(
153+
service_account.Credentials, "with_always_use_jwt_access", create=True
154+
) as use_jwt:
155+
creds = service_account.Credentials(None, None, None)
156+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
157+
use_jwt.assert_called_once_with(True)
140158

141159

142160
@pytest.mark.parametrize(
@@ -2087,13 +2105,7 @@ def test_metrics_service_v2_grpc_transport_client_cert_source_for_mtls(transport
20872105
"squid.clam.whelk:443",
20882106
credentials=cred,
20892107
credentials_file=None,
2090-
scopes=(
2091-
"https://www.googleapis.com/auth/cloud-platform",
2092-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2093-
"https://www.googleapis.com/auth/logging.admin",
2094-
"https://www.googleapis.com/auth/logging.read",
2095-
"https://www.googleapis.com/auth/logging.write",
2096-
),
2108+
scopes=None,
20972109
ssl_credentials=mock_ssl_channel_creds,
20982110
quota_project_id=None,
20992111
options=[
@@ -2202,13 +2214,7 @@ def test_metrics_service_v2_transport_channel_mtls_with_client_cert_source(
22022214
"mtls.squid.clam.whelk:443",
22032215
credentials=cred,
22042216
credentials_file=None,
2205-
scopes=(
2206-
"https://www.googleapis.com/auth/cloud-platform",
2207-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2208-
"https://www.googleapis.com/auth/logging.admin",
2209-
"https://www.googleapis.com/auth/logging.read",
2210-
"https://www.googleapis.com/auth/logging.write",
2211-
),
2217+
scopes=None,
22122218
ssl_credentials=mock_ssl_cred,
22132219
quota_project_id=None,
22142220
options=[
@@ -2255,13 +2261,7 @@ def test_metrics_service_v2_transport_channel_mtls_with_adc(transport_class):
22552261
"mtls.squid.clam.whelk:443",
22562262
credentials=mock_cred,
22572263
credentials_file=None,
2258-
scopes=(
2259-
"https://www.googleapis.com/auth/cloud-platform",
2260-
"https://www.googleapis.com/auth/cloud-platform.read-only",
2261-
"https://www.googleapis.com/auth/logging.admin",
2262-
"https://www.googleapis.com/auth/logging.read",
2263-
"https://www.googleapis.com/auth/logging.write",
2264-
),
2264+
scopes=None,
22652265
ssl_credentials=mock_ssl_cred,
22662266
quota_project_id=None,
22672267
options=[

0 commit comments

Comments
 (0)