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

Commit 099f589

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

12 files changed

Lines changed: 93 additions & 21 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6565
quota_project_id: Optional[str] = None,
6666
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
67+
always_use_jwt_access: Optional[bool] = False,
6768
) -> None:
6869
"""Instantiate the transport.
6970
@@ -104,6 +105,8 @@ def __init__(
104105
API requests. If ``None``, then default info will be used.
105106
Generally, you only need to set this if you're developing
106107
your own client library.
108+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
109+
be used for service account credentials.
107110
108111
Raises:
109112
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -156,7 +159,7 @@ def __init__(
156159
scopes=scopes,
157160
quota_project_id=quota_project_id,
158161
client_info=client_info,
159-
always_use_jwt_access=True,
162+
always_use_jwt_access=always_use_jwt_access,
160163
)
161164

162165
if not self._grpc_channel:

google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(
110110
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
111111
quota_project_id=None,
112112
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
113+
always_use_jwt_access: Optional[bool] = False,
113114
) -> None:
114115
"""Instantiate the transport.
115116
@@ -151,6 +152,8 @@ def __init__(
151152
API requests. If ``None``, then default info will be used.
152153
Generally, you only need to set this if you're developing
153154
your own client library.
155+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
156+
be used for service account credentials.
154157
155158
Raises:
156159
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -202,7 +205,7 @@ def __init__(
202205
scopes=scopes,
203206
quota_project_id=quota_project_id,
204207
client_info=client_info,
205-
always_use_jwt_access=True,
208+
always_use_jwt_access=always_use_jwt_access,
206209
)
207210

208211
if not self._grpc_channel:

google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py

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

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py

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

163166
if not self._grpc_channel:

google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py

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

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py

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

163166
if not self._grpc_channel:

google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114+
always_use_jwt_access: Optional[bool] = False,
114115
) -> None:
115116
"""Instantiate the transport.
116117
@@ -152,6 +153,8 @@ def __init__(
152153
API requests. If ``None``, then default info will be used.
153154
Generally, you only need to set this if you're developing
154155
your own client library.
156+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
157+
be used for service account credentials.
155158
156159
Raises:
157160
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -203,7 +206,7 @@ def __init__(
203206
scopes=scopes,
204207
quota_project_id=quota_project_id,
205208
client_info=client_info,
206-
always_use_jwt_access=True,
209+
always_use_jwt_access=always_use_jwt_access,
207210
)
208211

209212
if not self._grpc_channel:

tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,25 @@ def test_web_security_scanner_client_service_account_always_use_jwt(client_class
142142
) as use_jwt:
143143
creds = service_account.Credentials(None, None, None)
144144
client = client_class(credentials=creds)
145-
use_jwt.assert_called_with(True)
145+
use_jwt.assert_not_called()
146+
147+
148+
@pytest.mark.parametrize(
149+
"transport_class,transport_name",
150+
[
151+
(transports.WebSecurityScannerGrpcTransport, "grpc"),
152+
(transports.WebSecurityScannerGrpcAsyncIOTransport, "grpc_asyncio"),
153+
],
154+
)
155+
def test_web_security_scanner_client_service_account_always_use_jwt_true(
156+
transport_class, transport_name
157+
):
158+
with mock.patch.object(
159+
service_account.Credentials, "with_always_use_jwt_access", create=True
160+
) as use_jwt:
161+
creds = service_account.Credentials(None, None, None)
162+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
163+
use_jwt.assert_called_once_with(True)
146164

147165

148166
@pytest.mark.parametrize(
@@ -3485,7 +3503,7 @@ def test_web_security_scanner_grpc_transport_client_cert_source_for_mtls(
34853503
"squid.clam.whelk:443",
34863504
credentials=cred,
34873505
credentials_file=None,
3488-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3506+
scopes=None,
34893507
ssl_credentials=mock_ssl_channel_creds,
34903508
quota_project_id=None,
34913509
options=[
@@ -3594,7 +3612,7 @@ def test_web_security_scanner_transport_channel_mtls_with_client_cert_source(
35943612
"mtls.squid.clam.whelk:443",
35953613
credentials=cred,
35963614
credentials_file=None,
3597-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3615+
scopes=None,
35983616
ssl_credentials=mock_ssl_cred,
35993617
quota_project_id=None,
36003618
options=[
@@ -3641,7 +3659,7 @@ def test_web_security_scanner_transport_channel_mtls_with_adc(transport_class):
36413659
"mtls.squid.clam.whelk:443",
36423660
credentials=mock_cred,
36433661
credentials_file=None,
3644-
scopes=("https://www.googleapis.com/auth/cloud-platform",),
3662+
scopes=None,
36453663
ssl_credentials=mock_ssl_cred,
36463664
quota_project_id=None,
36473665
options=[

0 commit comments

Comments
 (0)