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

Commit cfca4f8

Browse files
1 parent a1749da commit cfca4f8

File tree

9 files changed

+63
-33
lines changed

9 files changed

+63
-33
lines changed

google/cloud/debugger_v2/services/controller2/transports/base.py

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

103103
# Save the scopes.
104-
self._scopes = scopes or self.AUTH_SCOPES
104+
self._scopes = scopes
105105

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

google/cloud/debugger_v2/services/controller2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __init__(
7878
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7979
quota_project_id: Optional[str] = None,
8080
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
81+
always_use_jwt_access: Optional[bool] = False,
8182
) -> None:
8283
"""Instantiate the transport.
8384
@@ -118,6 +119,8 @@ def __init__(
118119
API requests. If ``None``, then default info will be used.
119120
Generally, you only need to set this if you're developing
120121
your own client library.
122+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
123+
be used for service account credentials.
121124
122125
Raises:
123126
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -170,7 +173,7 @@ def __init__(
170173
scopes=scopes,
171174
quota_project_id=quota_project_id,
172175
client_info=client_info,
173-
always_use_jwt_access=True,
176+
always_use_jwt_access=always_use_jwt_access,
174177
)
175178

176179
if not self._grpc_channel:

google/cloud/debugger_v2/services/controller2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(
124124
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
125125
quota_project_id=None,
126126
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
127+
always_use_jwt_access: Optional[bool] = False,
127128
) -> None:
128129
"""Instantiate the transport.
129130
@@ -165,6 +166,8 @@ def __init__(
165166
API requests. If ``None``, then default info will be used.
166167
Generally, you only need to set this if you're developing
167168
your own client library.
169+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
170+
be used for service account credentials.
168171
169172
Raises:
170173
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -216,7 +219,7 @@ def __init__(
216219
scopes=scopes,
217220
quota_project_id=quota_project_id,
218221
client_info=client_info,
219-
always_use_jwt_access=True,
222+
always_use_jwt_access=always_use_jwt_access,
220223
)
221224

222225
if not self._grpc_channel:

google/cloud/debugger_v2/services/debugger2/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/debugger_v2/services/debugger2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(
7070
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7171
quota_project_id: Optional[str] = None,
7272
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
73+
always_use_jwt_access: Optional[bool] = False,
7374
) -> None:
7475
"""Instantiate the transport.
7576
@@ -110,6 +111,8 @@ def __init__(
110111
API requests. If ``None``, then default info will be used.
111112
Generally, you only need to set this if you're developing
112113
your own client library.
114+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
115+
be used for service account credentials.
113116
114117
Raises:
115118
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -162,7 +165,7 @@ def __init__(
162165
scopes=scopes,
163166
quota_project_id=quota_project_id,
164167
client_info=client_info,
165-
always_use_jwt_access=True,
168+
always_use_jwt_access=always_use_jwt_access,
166169
)
167170

168171
if not self._grpc_channel:

google/cloud/debugger_v2/services/debugger2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __init__(
116116
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
117117
quota_project_id=None,
118118
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
119+
always_use_jwt_access: Optional[bool] = False,
119120
) -> None:
120121
"""Instantiate the transport.
121122
@@ -157,6 +158,8 @@ def __init__(
157158
API requests. If ``None``, then default info will be used.
158159
Generally, you only need to set this if you're developing
159160
your own client library.
161+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
162+
be used for service account credentials.
160163
161164
Raises:
162165
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -208,7 +211,7 @@ def __init__(
208211
scopes=scopes,
209212
quota_project_id=quota_project_id,
210213
client_info=client_info,
211-
always_use_jwt_access=True,
214+
always_use_jwt_access=always_use_jwt_access,
212215
)
213216

214217
if not self._grpc_channel:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
release_status = "Development Status :: 4 - Beta"
2626
url = "https://github.com/googleapis/python-debugger-client"
2727
dependencies = [
28-
"google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
28+
"google-api-core[grpc] >= 1.26.0, <2.0.0dev",
2929
"proto-plus >= 1.15.0",
3030
"packaging >= 14.3",
3131
"google-cloud-source-context >= 0.1.0, < 1.0.0dev",

tests/unit/gapic/debugger_v2/test_controller2.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,25 @@ def test_controller2_client_service_account_always_use_jwt(client_class):
123123
) as use_jwt:
124124
creds = service_account.Credentials(None, None, None)
125125
client = client_class(credentials=creds)
126-
use_jwt.assert_called_with(True)
126+
use_jwt.assert_not_called()
127+
128+
129+
@pytest.mark.parametrize(
130+
"transport_class,transport_name",
131+
[
132+
(transports.Controller2GrpcTransport, "grpc"),
133+
(transports.Controller2GrpcAsyncIOTransport, "grpc_asyncio"),
134+
],
135+
)
136+
def test_controller2_client_service_account_always_use_jwt_true(
137+
transport_class, transport_name
138+
):
139+
with mock.patch.object(
140+
service_account.Credentials, "with_always_use_jwt_access", create=True
141+
) as use_jwt:
142+
creds = service_account.Credentials(None, None, None)
143+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
144+
use_jwt.assert_called_once_with(True)
127145

128146

129147
@pytest.mark.parametrize("client_class", [Controller2Client, Controller2AsyncClient,])
@@ -1232,10 +1250,7 @@ def test_controller2_grpc_transport_client_cert_source_for_mtls(transport_class)
12321250
"squid.clam.whelk:443",
12331251
credentials=cred,
12341252
credentials_file=None,
1235-
scopes=(
1236-
"https://www.googleapis.com/auth/cloud-platform",
1237-
"https://www.googleapis.com/auth/cloud_debugger",
1238-
),
1253+
scopes=None,
12391254
ssl_credentials=mock_ssl_channel_creds,
12401255
quota_project_id=None,
12411256
options=[
@@ -1339,10 +1354,7 @@ def test_controller2_transport_channel_mtls_with_client_cert_source(transport_cl
13391354
"mtls.squid.clam.whelk:443",
13401355
credentials=cred,
13411356
credentials_file=None,
1342-
scopes=(
1343-
"https://www.googleapis.com/auth/cloud-platform",
1344-
"https://www.googleapis.com/auth/cloud_debugger",
1345-
),
1357+
scopes=None,
13461358
ssl_credentials=mock_ssl_cred,
13471359
quota_project_id=None,
13481360
options=[
@@ -1386,10 +1398,7 @@ def test_controller2_transport_channel_mtls_with_adc(transport_class):
13861398
"mtls.squid.clam.whelk:443",
13871399
credentials=mock_cred,
13881400
credentials_file=None,
1389-
scopes=(
1390-
"https://www.googleapis.com/auth/cloud-platform",
1391-
"https://www.googleapis.com/auth/cloud_debugger",
1392-
),
1401+
scopes=None,
13931402
ssl_credentials=mock_ssl_cred,
13941403
quota_project_id=None,
13951404
options=[

tests/unit/gapic/debugger_v2/test_debugger2.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,25 @@ def test_debugger2_client_service_account_always_use_jwt(client_class):
120120
) as use_jwt:
121121
creds = service_account.Credentials(None, None, None)
122122
client = client_class(credentials=creds)
123-
use_jwt.assert_called_with(True)
123+
use_jwt.assert_not_called()
124+
125+
126+
@pytest.mark.parametrize(
127+
"transport_class,transport_name",
128+
[
129+
(transports.Debugger2GrpcTransport, "grpc"),
130+
(transports.Debugger2GrpcAsyncIOTransport, "grpc_asyncio"),
131+
],
132+
)
133+
def test_debugger2_client_service_account_always_use_jwt_true(
134+
transport_class, transport_name
135+
):
136+
with mock.patch.object(
137+
service_account.Credentials, "with_always_use_jwt_access", create=True
138+
) as use_jwt:
139+
creds = service_account.Credentials(None, None, None)
140+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
141+
use_jwt.assert_called_once_with(True)
124142

125143

126144
@pytest.mark.parametrize("client_class", [Debugger2Client, Debugger2AsyncClient,])
@@ -1545,10 +1563,7 @@ def test_debugger2_grpc_transport_client_cert_source_for_mtls(transport_class):
15451563
"squid.clam.whelk:443",
15461564
credentials=cred,
15471565
credentials_file=None,
1548-
scopes=(
1549-
"https://www.googleapis.com/auth/cloud-platform",
1550-
"https://www.googleapis.com/auth/cloud_debugger",
1551-
),
1566+
scopes=None,
15521567
ssl_credentials=mock_ssl_channel_creds,
15531568
quota_project_id=None,
15541569
options=[
@@ -1652,10 +1667,7 @@ def test_debugger2_transport_channel_mtls_with_client_cert_source(transport_clas
16521667
"mtls.squid.clam.whelk:443",
16531668
credentials=cred,
16541669
credentials_file=None,
1655-
scopes=(
1656-
"https://www.googleapis.com/auth/cloud-platform",
1657-
"https://www.googleapis.com/auth/cloud_debugger",
1658-
),
1670+
scopes=None,
16591671
ssl_credentials=mock_ssl_cred,
16601672
quota_project_id=None,
16611673
options=[
@@ -1699,10 +1711,7 @@ def test_debugger2_transport_channel_mtls_with_adc(transport_class):
16991711
"mtls.squid.clam.whelk:443",
17001712
credentials=mock_cred,
17011713
credentials_file=None,
1702-
scopes=(
1703-
"https://www.googleapis.com/auth/cloud-platform",
1704-
"https://www.googleapis.com/auth/cloud_debugger",
1705-
),
1714+
scopes=None,
17061715
ssl_credentials=mock_ssl_cred,
17071716
quota_project_id=None,
17081717
options=[

0 commit comments

Comments
 (0)