Skip to content

Commit 9add9d7

Browse files
fix: disable always_use_jwt_access (#39)
Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: googleapis/googleapis-gen@7b1e2c3
1 parent 50f6804 commit 9add9d7

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

packages/google-cloud-domains/google/cloud/domains_v1beta1/services/domains/transports/base.py

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

100100
# Save the scopes.
101-
self._scopes = scopes or self.AUTH_SCOPES
101+
self._scopes = scopes
102102

103103
# If no credentials are provided, then determine the appropriate
104104
# defaults.

packages/google-cloud-domains/google/cloud/domains_v1beta1/services/domains/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(
6060
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6161
quota_project_id: Optional[str] = None,
6262
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
63+
always_use_jwt_access: Optional[bool] = False,
6364
) -> None:
6465
"""Instantiate the transport.
6566
@@ -100,6 +101,8 @@ def __init__(
100101
API requests. If ``None``, then default info will be used.
101102
Generally, you only need to set this if you're developing
102103
your own client library.
104+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
105+
be used for service account credentials.
103106
104107
Raises:
105108
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -153,7 +156,7 @@ def __init__(
153156
scopes=scopes,
154157
quota_project_id=quota_project_id,
155158
client_info=client_info,
156-
always_use_jwt_access=True,
159+
always_use_jwt_access=always_use_jwt_access,
157160
)
158161

159162
if not self._grpc_channel:

packages/google-cloud-domains/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__(
106106
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
107107
quota_project_id=None,
108108
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
109+
always_use_jwt_access: Optional[bool] = False,
109110
) -> None:
110111
"""Instantiate the transport.
111112
@@ -147,6 +148,8 @@ def __init__(
147148
API requests. If ``None``, then default info will be used.
148149
Generally, you only need to set this if you're developing
149150
your own client library.
151+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
152+
be used for service account credentials.
150153
151154
Raises:
152155
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -199,7 +202,7 @@ def __init__(
199202
scopes=scopes,
200203
quota_project_id=quota_project_id,
201204
client_info=client_info,
202-
always_use_jwt_access=True,
205+
always_use_jwt_access=always_use_jwt_access,
203206
)
204207

205208
if not self._grpc_channel:

packages/google-cloud-domains/tests/unit/gapic/domains_v1beta1/test_domains.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,25 @@ def test_domains_client_service_account_always_use_jwt(client_class):
125125
) as use_jwt:
126126
creds = service_account.Credentials(None, None, None)
127127
client = client_class(credentials=creds)
128-
use_jwt.assert_called_with(True)
128+
use_jwt.assert_not_called()
129+
130+
131+
@pytest.mark.parametrize(
132+
"transport_class,transport_name",
133+
[
134+
(transports.DomainsGrpcTransport, "grpc"),
135+
(transports.DomainsGrpcAsyncIOTransport, "grpc_asyncio"),
136+
],
137+
)
138+
def test_domains_client_service_account_always_use_jwt_true(
139+
transport_class, transport_name
140+
):
141+
with mock.patch.object(
142+
service_account.Credentials, "with_always_use_jwt_access", create=True
143+
) as use_jwt:
144+
creds = service_account.Credentials(None, None, None)
145+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
146+
use_jwt.assert_called_once_with(True)
129147

130148

131149
@pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,])
@@ -3757,7 +3775,7 @@ def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class):
37573775
"squid.clam.whelk:443",
37583776
credentials=cred,
37593777
credentials_file=None,
3760-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3778+
scopes=None,
37613779
ssl_credentials=mock_ssl_channel_creds,
37623780
quota_project_id=None,
37633781
options=[
@@ -3861,7 +3879,7 @@ def test_domains_transport_channel_mtls_with_client_cert_source(transport_class)
38613879
"mtls.squid.clam.whelk:443",
38623880
credentials=cred,
38633881
credentials_file=None,
3864-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3882+
scopes=None,
38653883
ssl_credentials=mock_ssl_cred,
38663884
quota_project_id=None,
38673885
options=[
@@ -3905,7 +3923,7 @@ def test_domains_transport_channel_mtls_with_adc(transport_class):
39053923
"mtls.squid.clam.whelk:443",
39063924
credentials=mock_cred,
39073925
credentials_file=None,
3908-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3926+
scopes=None,
39093927
ssl_credentials=mock_ssl_cred,
39103928
quota_project_id=None,
39113929
options=[

0 commit comments

Comments
 (0)