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

Commit 3d347fa

Browse files
fix: disable always_use_jwt_access (#63)
fix: disable always_use_jwt_access Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0
1 parent 2795783 commit 3d347fa

File tree

7 files changed

+54
-6
lines changed

7 files changed

+54
-6
lines changed

dataqna-v1alpha-py.tar.gz

Whitespace-only changes.

google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def __init__(
127127
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
128128
quota_project_id: Optional[str] = None,
129129
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
130+
always_use_jwt_access: Optional[bool] = False,
130131
) -> None:
131132
"""Instantiate the transport.
132133
@@ -167,6 +168,8 @@ def __init__(
167168
API requests. If ``None``, then default info will be used.
168169
Generally, you only need to set this if you're developing
169170
your own client library.
171+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
172+
be used for service account credentials.
170173
171174
Raises:
172175
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -219,7 +222,7 @@ def __init__(
219222
scopes=scopes,
220223
quota_project_id=quota_project_id,
221224
client_info=client_info,
222-
always_use_jwt_access=True,
225+
always_use_jwt_access=always_use_jwt_access,
223226
)
224227

225228
if not self._grpc_channel:

google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def __init__(
173173
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
174174
quota_project_id=None,
175175
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
176+
always_use_jwt_access: Optional[bool] = False,
176177
) -> None:
177178
"""Instantiate the transport.
178179
@@ -214,6 +215,8 @@ def __init__(
214215
API requests. If ``None``, then default info will be used.
215216
Generally, you only need to set this if you're developing
216217
your own client library.
218+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
219+
be used for service account credentials.
217220
218221
Raises:
219222
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -265,7 +268,7 @@ def __init__(
265268
scopes=scopes,
266269
quota_project_id=quota_project_id,
267270
client_info=client_info,
268-
always_use_jwt_access=True,
271+
always_use_jwt_access=always_use_jwt_access,
269272
)
270273

271274
if not self._grpc_channel:

google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py

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

175178
if not self._grpc_channel:

google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def __init__(
123123
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
124124
quota_project_id=None,
125125
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
126+
always_use_jwt_access: Optional[bool] = False,
126127
) -> None:
127128
"""Instantiate the transport.
128129
@@ -164,6 +165,8 @@ def __init__(
164165
API requests. If ``None``, then default info will be used.
165166
Generally, you only need to set this if you're developing
166167
your own client library.
168+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
169+
be used for service account credentials.
167170
168171
Raises:
169172
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -215,7 +218,7 @@ def __init__(
215218
scopes=scopes,
216219
quota_project_id=quota_project_id,
217220
client_info=client_info,
218-
always_use_jwt_access=True,
221+
always_use_jwt_access=always_use_jwt_access,
219222
)
220223

221224
if not self._grpc_channel:

tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,25 @@ def test_auto_suggestion_service_client_service_account_always_use_jwt(client_cl
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.AutoSuggestionServiceGrpcTransport, "grpc"),
141+
(transports.AutoSuggestionServiceGrpcAsyncIOTransport, "grpc_asyncio"),
142+
],
143+
)
144+
def test_auto_suggestion_service_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(

tests/unit/gapic/dataqna_v1alpha/test_question_service.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,25 @@ def test_question_service_client_service_account_always_use_jwt(client_class):
137137
) as use_jwt:
138138
creds = service_account.Credentials(None, None, None)
139139
client = client_class(credentials=creds)
140-
use_jwt.assert_called_with(True)
140+
use_jwt.assert_not_called()
141+
142+
143+
@pytest.mark.parametrize(
144+
"transport_class,transport_name",
145+
[
146+
(transports.QuestionServiceGrpcTransport, "grpc"),
147+
(transports.QuestionServiceGrpcAsyncIOTransport, "grpc_asyncio"),
148+
],
149+
)
150+
def test_question_service_client_service_account_always_use_jwt_true(
151+
transport_class, transport_name
152+
):
153+
with mock.patch.object(
154+
service_account.Credentials, "with_always_use_jwt_access", create=True
155+
) as use_jwt:
156+
creds = service_account.Credentials(None, None, None)
157+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
158+
use_jwt.assert_called_once_with(True)
141159

142160

143161
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)