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

Commit 9725e35

Browse files
1 parent 2bcb88e commit 9725e35

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/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.

google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6060
quota_project_id: Optional[str] = None,
6161
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
62+
always_use_jwt_access: Optional[bool] = False,
6263
) -> None:
6364
"""Instantiate the transport.
6465
@@ -99,6 +100,8 @@ def __init__(
99100
API requests. If ``None``, then default info will be used.
100101
Generally, you only need to set this if you're developing
101102
your own client library.
103+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
104+
be used for service account credentials.
102105
103106
Raises:
104107
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -151,7 +154,7 @@ def __init__(
151154
scopes=scopes,
152155
quota_project_id=quota_project_id,
153156
client_info=client_info,
154-
always_use_jwt_access=True,
157+
always_use_jwt_access=always_use_jwt_access,
155158
)
156159

157160
if not self._grpc_channel:

google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(
105105
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
106106
quota_project_id=None,
107107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
108+
always_use_jwt_access: Optional[bool] = False,
108109
) -> None:
109110
"""Instantiate the transport.
110111
@@ -146,6 +147,8 @@ def __init__(
146147
API requests. If ``None``, then default info will be used.
147148
Generally, you only need to set this if you're developing
148149
your own client library.
150+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
151+
be used for service account credentials.
149152
150153
Raises:
151154
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -197,7 +200,7 @@ def __init__(
197200
scopes=scopes,
198201
quota_project_id=quota_project_id,
199202
client_info=client_info,
200-
always_use_jwt_access=True,
203+
always_use_jwt_access=always_use_jwt_access,
201204
)
202205

203206
if not self._grpc_channel:

tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,28 @@ def test_phishing_protection_service_v1_beta1_client_service_account_always_use_
153153
) as use_jwt:
154154
creds = service_account.Credentials(None, None, None)
155155
client = client_class(credentials=creds)
156-
use_jwt.assert_called_with(True)
156+
use_jwt.assert_not_called()
157+
158+
159+
@pytest.mark.parametrize(
160+
"transport_class,transport_name",
161+
[
162+
(transports.PhishingProtectionServiceV1Beta1GrpcTransport, "grpc"),
163+
(
164+
transports.PhishingProtectionServiceV1Beta1GrpcAsyncIOTransport,
165+
"grpc_asyncio",
166+
),
167+
],
168+
)
169+
def test_phishing_protection_service_v1_beta1_client_service_account_always_use_jwt_true(
170+
transport_class, transport_name
171+
):
172+
with mock.patch.object(
173+
service_account.Credentials, "with_always_use_jwt_access", create=True
174+
) as use_jwt:
175+
creds = service_account.Credentials(None, None, None)
176+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
177+
use_jwt.assert_called_once_with(True)
157178

158179

159180
@pytest.mark.parametrize(
@@ -1034,7 +1055,7 @@ def test_phishing_protection_service_v1_beta1_grpc_transport_client_cert_source_
10341055
"squid.clam.whelk:443",
10351056
credentials=cred,
10361057
credentials_file=None,
1037-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1058+
scopes=None,
10381059
ssl_credentials=mock_ssl_channel_creds,
10391060
quota_project_id=None,
10401061
options=[
@@ -1143,7 +1164,7 @@ def test_phishing_protection_service_v1_beta1_transport_channel_mtls_with_client
11431164
"mtls.squid.clam.whelk:443",
11441165
credentials=cred,
11451166
credentials_file=None,
1146-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1167+
scopes=None,
11471168
ssl_credentials=mock_ssl_cred,
11481169
quota_project_id=None,
11491170
options=[
@@ -1192,7 +1213,7 @@ def test_phishing_protection_service_v1_beta1_transport_channel_mtls_with_adc(
11921213
"mtls.squid.clam.whelk:443",
11931214
credentials=mock_cred,
11941215
credentials_file=None,
1195-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
1216+
scopes=None,
11961217
ssl_credentials=mock_ssl_cred,
11971218
quota_project_id=None,
11981219
options=[

0 commit comments

Comments
 (0)