Skip to content

Commit a96483a

Browse files
committed
lint fixes.
1 parent 5e27322 commit a96483a

6 files changed

Lines changed: 40 additions & 22 deletions

File tree

packages/google-auth/google/auth/_agent_identity_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def should_request_bound_token(cert):
330330
# if the transport is capable of handling it.
331331
if use_client_cert is None or use_client_cert == "":
332332
from google.auth.transport import _mtls_helper
333+
333334
if not _mtls_helper.is_transport_mtls_capable():
334335
return False
335336

packages/google-auth/google/auth/aio/transport/sessions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ def __init__(
150150
async def configure_mtls_channel(self, client_cert_callback=None):
151151
"""Configure the client certificate and key for SSL connection.
152152
153-
This method configures mTLS if client certificates are explicitly enabled
154-
(via GOOGLE_API_USE_CLIENT_CERTIFICATE=true) or auto-enabled (when the env
155-
variable is unset and workload certificates are discovered). In these cases,
153+
This method configures mTLS if client certificates are explicitly enabled
154+
(via GOOGLE_API_USE_CLIENT_CERTIFICATE=true) or auto-enabled (when the env
155+
variable is unset and workload certificates are discovered). In these cases,
156156
the underlying transport will be reconfigured to use mTLS.
157157
158158
Note: This function does nothing if the `aiohttp` library is not
@@ -170,7 +170,7 @@ async def configure_mtls_channel(self, client_cert_callback=None):
170170
171171
Raises:
172172
google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
173-
creation failed for any reason (e.g., missing dependencies, custom request
173+
creation failed for any reason (e.g., missing dependencies, custom request
174174
handler limitations, or missing certificates when mTLS was requested).
175175
"""
176176
if self._mtls_init_task is None:

packages/google-auth/google/auth/transport/_mtls_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def is_transport_mtls_capable():
457457
try:
458458
import OpenSSL
459459
from cryptography import x509
460+
460461
return True
461462
except ImportError:
462463
return False

packages/google-auth/google/auth/transport/requests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ def __init__(
428428
def configure_mtls_channel(self, client_cert_callback=None):
429429
"""Configure the client certificate and key for SSL connection.
430430
431-
This method configures mTLS if client certificates are explicitly enabled
432-
(via GOOGLE_API_USE_CLIENT_CERTIFICATE=true) or auto-enabled (when the env
431+
This method configures mTLS if client certificates are explicitly enabled
432+
(via GOOGLE_API_USE_CLIENT_CERTIFICATE=true) or auto-enabled (when the env
433433
variable is unset and workload certificates are discovered). In these cases,
434-
if the client certificate and key are successfully obtained, a
434+
if the client certificate and key are successfully obtained, a
435435
:class:`_MutualTlsAdapter` instance will be mounted to the "https://" prefix.
436436
437437
Args:
@@ -443,7 +443,7 @@ def configure_mtls_channel(self, client_cert_callback=None):
443443
444444
Raises:
445445
google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
446-
creation failed for any reason (e.g. missing dependencies, missing
446+
creation failed for any reason (e.g. missing dependencies, missing
447447
certificates when explicitly requested, or custom request adapter issues).
448448
"""
449449
use_client_cert = google.auth.transport._mtls_helper.check_use_client_cert()

packages/google-auth/google/auth/transport/urllib3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ def __init__(
313313

314314
def configure_mtls_channel(self, client_cert_callback=None):
315315
"""Configures mutual TLS channel using the given client_cert_callback or
316-
application default SSL credentials.
316+
application default SSL credentials.
317317
318-
The channel is configured if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true",
319-
or if it is unset and workload certificates are detected in the environment.
320-
If client_cert_callback is None, default SSL credentials (workload or SecureConnect)
321-
are loaded.
318+
The channel is configured if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true",
319+
or if it is unset and workload certificates are detected in the environment.
320+
If client_cert_callback is None, default SSL credentials (workload or SecureConnect)
321+
are loaded.
322322
323323
Args:
324324
client_cert_callback (Optional[Callable[[], (bytes, bytes)]]):
@@ -332,7 +332,7 @@ def configure_mtls_channel(self, client_cert_callback=None):
332332
333333
Raises:
334334
google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
335-
creation failed for any reason (e.g., missing dependencies, or missing
335+
creation failed for any reason (e.g., missing dependencies, or missing
336336
certificates when mTLS was explicitly/implicitly requested).
337337
"""
338338
use_client_cert = transport._mtls_helper.check_use_client_cert()

packages/google-auth/tests/transport/test__mtls_helper.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,33 +911,49 @@ def test_check_use_client_cert_config_fallback(self, mock_file):
911911

912912
assert _mtls_helper.check_use_client_cert() is True
913913

914-
@mock.patch("google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True)
914+
@mock.patch(
915+
"google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True
916+
)
915917
@mock.patch("os.path.exists", autospec=True)
916918
@mock.patch("os.path.getsize", autospec=True)
917919
@mock.patch.dict(os.environ, {}, clear=True)
918920
def test_well_known_path_success(self, mock_getsize, mock_exists, mock_capable):
919921
mock_capable.return_value = True
920-
mock_exists.side_effect = lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
922+
mock_exists.side_effect = (
923+
lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
924+
)
921925
mock_getsize.return_value = 100
922926
assert _mtls_helper.check_use_client_cert() is True
923927

924-
@mock.patch("google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True)
928+
@mock.patch(
929+
"google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True
930+
)
925931
@mock.patch("os.path.exists", autospec=True)
926932
@mock.patch("os.path.getsize", autospec=True)
927933
@mock.patch.dict(os.environ, {}, clear=True)
928934
def test_well_known_path_incapable(self, mock_getsize, mock_exists, mock_capable):
929935
mock_capable.return_value = False
930-
mock_exists.side_effect = lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
936+
mock_exists.side_effect = (
937+
lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
938+
)
931939
mock_getsize.return_value = 100
932940
assert _mtls_helper.check_use_client_cert() is False
933941

934-
@mock.patch("google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True)
942+
@mock.patch(
943+
"google.auth.transport._mtls_helper.is_transport_mtls_capable", autospec=True
944+
)
935945
@mock.patch("os.path.exists", autospec=True)
936946
@mock.patch("os.path.getsize", autospec=True)
937-
@mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}, clear=True)
938-
def test_explicit_opt_out_with_well_known_path(self, mock_getsize, mock_exists, mock_capable):
947+
@mock.patch.dict(
948+
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}, clear=True
949+
)
950+
def test_explicit_opt_out_with_well_known_path(
951+
self, mock_getsize, mock_exists, mock_capable
952+
):
939953
mock_capable.return_value = True
940-
mock_exists.side_effect = lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
954+
mock_exists.side_effect = (
955+
lambda p: p == _mtls_helper._WELL_KNOWN_SPIFFE_CERT_PATH
956+
)
941957
mock_getsize.return_value = 100
942958
assert _mtls_helper.check_use_client_cert() is False
943959

0 commit comments

Comments
 (0)