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

Commit 15f189f

Browse files
1 parent 80a99bc commit 15f189f

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

google/cloud/dlp_v2/services/dlp_service/transports/base.py

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

9999
# Save the scopes.
100-
self._scopes = scopes or self.AUTH_SCOPES
100+
self._scopes = scopes
101101

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

google/cloud/dlp_v2/services/dlp_service/transports/grpc.py

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

164167
if not self._grpc_channel:

google/cloud/dlp_v2/services/dlp_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def __init__(
112112
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
113113
quota_project_id=None,
114114
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
115+
always_use_jwt_access: Optional[bool] = False,
115116
) -> None:
116117
"""Instantiate the transport.
117118
@@ -153,6 +154,8 @@ def __init__(
153154
API requests. If ``None``, then default info will be used.
154155
Generally, you only need to set this if you're developing
155156
your own client library.
157+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
158+
be used for service account credentials.
156159
157160
Raises:
158161
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -204,7 +207,7 @@ def __init__(
204207
scopes=scopes,
205208
quota_project_id=quota_project_id,
206209
client_info=client_info,
207-
always_use_jwt_access=True,
210+
always_use_jwt_access=always_use_jwt_access,
208211
)
209212

210213
if not self._grpc_channel:

tests/unit/gapic/dlp_v2/test_dlp_service.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,25 @@ def test_dlp_service_client_service_account_always_use_jwt(client_class):
129129
) as use_jwt:
130130
creds = service_account.Credentials(None, None, None)
131131
client = client_class(credentials=creds)
132-
use_jwt.assert_called_with(True)
132+
use_jwt.assert_not_called()
133+
134+
135+
@pytest.mark.parametrize(
136+
"transport_class,transport_name",
137+
[
138+
(transports.DlpServiceGrpcTransport, "grpc"),
139+
(transports.DlpServiceGrpcAsyncIOTransport, "grpc_asyncio"),
140+
],
141+
)
142+
def test_dlp_service_client_service_account_always_use_jwt_true(
143+
transport_class, transport_name
144+
):
145+
with mock.patch.object(
146+
service_account.Credentials, "with_always_use_jwt_access", create=True
147+
) as use_jwt:
148+
creds = service_account.Credentials(None, None, None)
149+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
150+
use_jwt.assert_called_once_with(True)
133151

134152

135153
@pytest.mark.parametrize("client_class", [DlpServiceClient, DlpServiceAsyncClient,])
@@ -8268,7 +8286,7 @@ def test_dlp_service_grpc_transport_client_cert_source_for_mtls(transport_class)
82688286
"squid.clam.whelk:443",
82698287
credentials=cred,
82708288
credentials_file=None,
8271-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
8289+
scopes=None,
82728290
ssl_credentials=mock_ssl_channel_creds,
82738291
quota_project_id=None,
82748292
options=[
@@ -8370,7 +8388,7 @@ def test_dlp_service_transport_channel_mtls_with_client_cert_source(transport_cl
83708388
"mtls.squid.clam.whelk:443",
83718389
credentials=cred,
83728390
credentials_file=None,
8373-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
8391+
scopes=None,
83748392
ssl_credentials=mock_ssl_cred,
83758393
quota_project_id=None,
83768394
options=[
@@ -8414,7 +8432,7 @@ def test_dlp_service_transport_channel_mtls_with_adc(transport_class):
84148432
"mtls.squid.clam.whelk:443",
84158433
credentials=mock_cred,
84168434
credentials_file=None,
8417-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
8435+
scopes=None,
84188436
ssl_credentials=mock_ssl_cred,
84198437
quota_project_id=None,
84208438
options=[

0 commit comments

Comments
 (0)