From cc424a78ffa8cd73a1773a7f1bedd7e6d145b4dc Mon Sep 17 00:00:00 2001 From: nbayati <99771966+nbayati@users.noreply.github.com> Date: Wed, 24 Jun 2026 20:39:37 -0700 Subject: [PATCH 1/5] fix(auth): lower regional access boundary logs from warning to info When the library tries to look up Regional Access Boundaries in the background and fails, it used to print a "WARNING" message. Because these lookups are optional and failing is not considered fatal or blocking, omitting warnings creates a lot of log noise for the users. This change lowers those messages to the "INFO" level so they stay out of the way by default. --- .../auth/_regional_access_boundary_utils.py | 100 ++++++++---------- .../google-auth/google/auth/credentials.py | 2 +- packages/google-auth/google/oauth2/_client.py | 2 +- .../google/oauth2/_client_async.py | 2 +- .../test__regional_access_boundary_utils.py | 42 +++++++- 5 files changed, 88 insertions(+), 60 deletions(-) diff --git a/packages/google-auth/google/auth/_regional_access_boundary_utils.py b/packages/google-auth/google/auth/_regional_access_boundary_utils.py index 9b055b0dde68..90d8f2484161 100644 --- a/packages/google-auth/google/auth/_regional_access_boundary_utils.py +++ b/packages/google-auth/google/auth/_regional_access_boundary_utils.py @@ -219,10 +219,9 @@ def start_blocking_refresh(self, credentials, request): """ # Async credentials do not support blocking lookups. if inspect.iscoroutinefunction(credentials._lookup_regional_access_boundary): - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Blocking Regional Access Boundary lookup is not supported for async credentials." - ) + _LOGGER.info( + "Blocking Regional Access Boundary lookup is not supported for async credentials." + ) self.process_regional_access_boundary_info(None) return @@ -234,12 +233,11 @@ def start_blocking_refresh(self, credentials, request): credentials._lookup_regional_access_boundary(request, fail_fast=True) ) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Blocking Regional Access Boundary lookup raised an exception: %s", - e, - exc_info=True, - ) + _LOGGER.info( + "Blocking Regional Access Boundary lookup raised an exception: %s", + e, + exc_info=True, + ) regional_access_boundary_info = None self.process_regional_access_boundary_info(regional_access_boundary_info) @@ -265,12 +263,11 @@ async def start_blocking_refresh_async(self, credentials, request): ) ) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Regional Access Boundary lookup raised an exception: %s", - e, - exc_info=True, - ) + _LOGGER.info( + "Regional Access Boundary lookup raised an exception: %s", + e, + exc_info=True, + ) regional_access_boundary_info = None self.process_regional_access_boundary_info(regional_access_boundary_info) @@ -297,14 +294,12 @@ def process_regional_access_boundary_info(self, regional_access_boundary_info): cooldown_expiry=None, cooldown_duration=DEFAULT_REGIONAL_ACCESS_BOUNDARY_COOLDOWN, ) - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.debug("Regional Access Boundary lookup successful.") + _LOGGER.info("Regional Access Boundary lookup successful.") else: # On failure, calculate cooldown and update state. - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Regional Access Boundary lookup failed. Entering cooldown." - ) + _LOGGER.info( + "Regional Access Boundary lookup failed. Entering cooldown." + ) next_cooldown_expiry = ( _helpers.utcnow() + current_data.cooldown_duration @@ -367,12 +362,11 @@ def run(self): self._credentials._lookup_regional_access_boundary(self._request) ) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Asynchronous Regional Access Boundary lookup raised an exception: %s", - e, - exc_info=True, - ) + _LOGGER.info( + "Asynchronous Regional Access Boundary lookup raised an exception: %s", + e, + exc_info=True, + ) regional_access_boundary_info = None self._rab_manager.process_regional_access_boundary_info( @@ -419,13 +413,12 @@ def start_refresh(self, credentials, request, rab_manager): try: copied_request = copy.deepcopy(request) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Could not deepcopy transport for background RAB refresh. " - "Skipping background refresh to avoid thread safety issues. " - "Exception: %s", - e, - ) + _LOGGER.info( + "Could not deepcopy transport for background RAB refresh. " + "Skipping background refresh to avoid thread safety issues. " + "Exception: %s", + e, + ) return self._worker = _RegionalAccessBoundaryRefreshThread( @@ -479,14 +472,13 @@ async def _close_cloned_request(lookup_request, is_cloned): if is_async := inspect.isawaitable(maybe_coro): await maybe_coro except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - adapter_type = " asynchronous " if is_async else " " - _LOGGER.warning( - "Failed to cleanly close cloned%srequest transport: %s", - adapter_type, - e, - exc_info=True, - ) + adapter_type = " asynchronous " if is_async else " " + _LOGGER.info( + "Failed to cleanly close cloned%srequest transport: %s", + adapter_type, + e, + exc_info=True, + ) class _AsyncRegionalAccessBoundaryRefreshManager(object): @@ -532,12 +524,11 @@ def start_refresh(self, credentials, request, rab_manager): is_cloned, ) = _prepare_async_lookup_callable(request) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Synchronous cloning of request for Regional Access Boundary lookup failed: %s", - e, - exc_info=True, - ) + _LOGGER.info( + "Synchronous cloning of request for Regional Access Boundary lookup failed: %s", + e, + exc_info=True, + ) rab_manager.process_regional_access_boundary_info(None) return @@ -549,12 +540,11 @@ async def _worker(): ) ) except Exception as e: - if _helpers.is_logging_enabled(_LOGGER): - _LOGGER.warning( - "Asynchronous Regional Access Boundary lookup raised an exception: %s", - e, - exc_info=True, - ) + _LOGGER.info( + "Asynchronous Regional Access Boundary lookup raised an exception: %s", + e, + exc_info=True, + ) regional_access_boundary_info = None finally: await _close_cloned_request(lookup_request, is_cloned) diff --git a/packages/google-auth/google/auth/credentials.py b/packages/google-auth/google/auth/credentials.py index 95aa2cf3503f..0c7bc400099f 100644 --- a/packages/google-auth/google/auth/credentials.py +++ b/packages/google-auth/google/auth/credentials.py @@ -535,7 +535,7 @@ def _lookup_regional_access_boundary( url = self._build_regional_access_boundary_lookup_url(request=request) if not url: - _LOGGER.warning("Failed to build Regional Access Boundary lookup URL.") + _LOGGER.info("Failed to build Regional Access Boundary lookup URL.") return None headers: Dict[str, str] = {} diff --git a/packages/google-auth/google/oauth2/_client.py b/packages/google-auth/google/oauth2/_client.py index 88083d022986..f79fcd672bf7 100644 --- a/packages/google-auth/google/oauth2/_client.py +++ b/packages/google-auth/google/oauth2/_client.py @@ -582,7 +582,7 @@ def _lookup_regional_access_boundary_request( request, url, can_retry=can_retry, headers=headers, fail_fast=fail_fast ) if not response_status_ok: - _LOGGER.warning( + _LOGGER.info( "Regional Access Boundary HTTP request failed after retries: response_data=%s, retryable_error=%s", response_data, retryable_error, diff --git a/packages/google-auth/google/oauth2/_client_async.py b/packages/google-auth/google/oauth2/_client_async.py index ce94284ea7c9..67ed09ab2a23 100644 --- a/packages/google-auth/google/oauth2/_client_async.py +++ b/packages/google-auth/google/oauth2/_client_async.py @@ -356,7 +356,7 @@ async def _lookup_regional_access_boundary_request( request, url, can_retry=can_retry, headers=headers, fail_fast=fail_fast ) if not response_status_ok: - client._LOGGER.warning( + client._LOGGER.info( "Regional Access Boundary HTTP request failed after retries: response_data=%s, retryable_error=%s", response_data, retryable_error, diff --git a/packages/google-auth/tests/test__regional_access_boundary_utils.py b/packages/google-auth/tests/test__regional_access_boundary_utils.py index 6746cf854405..201976c2741d 100644 --- a/packages/google-auth/tests/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests/test__regional_access_boundary_utils.py @@ -13,6 +13,7 @@ # limitations under the License. import datetime +import logging from unittest import mock import pytest # type: ignore @@ -24,6 +25,21 @@ from google.oauth2 import credentials as oauth2_credentials +@pytest.fixture +def rab_caplog(caplog): + """Fixture to configure logging capture and ensure propagation for RAB utilities.""" + + caplog.set_level(logging.INFO, logger="google.auth._regional_access_boundary_utils") + + google_logger = logging.getLogger("google") + original_propagate = google_logger.propagate + google_logger.propagate = True + try: + yield caplog + finally: + google_logger.propagate = original_propagate + + class CredentialsImpl(credentials.CredentialsWithRegionalAccessBoundary): def __init__(self, universe_domain=None): super(CredentialsImpl, self).__init__() @@ -379,7 +395,7 @@ def test_lookup_regional_access_boundary_success(self, mock_lookup_rab): assert rab_manager._data.cooldown_expiry is None @mock.patch.object(CredentialsImpl, "_lookup_regional_access_boundary") - def test_lookup_regional_access_boundary_failure(self, mock_lookup_rab): + def test_lookup_regional_access_boundary_failure(self, mock_lookup_rab, rab_caplog): creds = CredentialsImpl() request = mock.Mock() rab_manager = _regional_access_boundary_utils._RegionalAccessBoundaryManager() @@ -396,6 +412,14 @@ def test_lookup_regional_access_boundary_failure(self, mock_lookup_rab): assert rab_manager._data.expiry is None assert rab_manager._data.cooldown_expiry is not None + assert ( + "Regional Access Boundary lookup failed. Entering cooldown." + in rab_caplog.text + ) + # RAB failures should be logged at INFO level. + warning_logs = [t for t in rab_caplog.record_tuples if t[1] == logging.WARNING] + assert not warning_logs, f"Unexpected warnings emitted: {warning_logs}" + def test_lookup_regional_access_boundary_null_url(self): creds = oauth2_credentials.Credentials(token="token") request = mock.Mock() @@ -441,7 +465,9 @@ def test_regional_access_boundary_refresh_thread_run_success(self, mock_utcnow): assert rab_manager._data.cooldown_expiry is None @mock.patch("google.auth._helpers.utcnow") - def test_regional_access_boundary_refresh_thread_run_failure(self, mock_utcnow): + def test_regional_access_boundary_refresh_thread_run_failure( + self, mock_utcnow, rab_caplog + ): mock_now = datetime.datetime(2025, 1, 1, 12, 0, 0) mock_utcnow.return_value = mock_now @@ -466,6 +492,18 @@ def test_regional_access_boundary_refresh_thread_run_failure(self, mock_utcnow): assert rab_manager._data.cooldown_expiry == expected_cooldown_expiry assert rab_manager._data.cooldown_duration == initial_cooldown * 2 + assert ( + "Asynchronous Regional Access Boundary lookup raised an exception" + in rab_caplog.text + ) + assert ( + "Regional Access Boundary lookup failed. Entering cooldown." + in rab_caplog.text + ) + # RAB failures should be logged at INFO level. + warning_logs = [t for t in rab_caplog.record_tuples if t[1] == logging.WARNING] + assert not warning_logs, f"Unexpected warnings emitted: {warning_logs}" + @mock.patch("google.auth._helpers.utcnow") def test_regional_access_boundary_refresh_thread_run_failure_hard_expiry( self, mock_utcnow From f7183b2259162ffdbd7b201091cf760626fbbb04 Mon Sep 17 00:00:00 2001 From: nbayati <99771966+nbayati@users.noreply.github.com> Date: Thu, 25 Jun 2026 08:47:17 -0700 Subject: [PATCH 2/5] test(auth): update async RAB logging tests for INFO level --- .../test__regional_access_boundary_utils.py | 47 ++----------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/packages/google-auth/tests_async/test__regional_access_boundary_utils.py b/packages/google-auth/tests_async/test__regional_access_boundary_utils.py index dd8a9eae2d8a..4c6c9bd034aa 100644 --- a/packages/google-auth/tests_async/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests_async/test__regional_access_boundary_utils.py @@ -195,7 +195,7 @@ def test_async_refresh_manager_pickle(): @pytest.mark.asyncio -async def test_async_worker_exception_logging_enabled(monkeypatch): +async def test_async_worker_exception_logging(): credentials = mock.AsyncMock() credentials._lookup_regional_access_boundary.side_effect = Exception("lookup fail") @@ -203,55 +203,18 @@ async def test_async_worker_exception_logging_enabled(monkeypatch): request._clone.return_value = request rab_manager = mock.Mock() - # Force is_logging_enabled to return True - monkeypatch.setattr( - _regional_access_boundary_utils._helpers, - "is_logging_enabled", - lambda logger: True, - ) - - manager = ( - _regional_access_boundary_utils._AsyncRegionalAccessBoundaryRefreshManager() - ) - - with mock.patch.object( - _regional_access_boundary_utils._LOGGER, "warning" - ) as mock_warning: - manager.start_refresh(credentials, request, rab_manager) - await manager._worker_task - - mock_warning.assert_called_once() - assert "lookup raised an exception" in mock_warning.call_args[0][0] - rab_manager.process_regional_access_boundary_info.assert_called_once_with(None) - - -@pytest.mark.asyncio -async def test_async_worker_exception_logging_disabled(monkeypatch): - credentials = mock.AsyncMock() - credentials._lookup_regional_access_boundary.side_effect = Exception("lookup fail") - - request = mock.Mock() - request._clone.return_value = request - rab_manager = mock.Mock() - - # Force is_logging_enabled to return False - monkeypatch.setattr( - _regional_access_boundary_utils._helpers, - "is_logging_enabled", - lambda logger: False, - ) - manager = ( _regional_access_boundary_utils._AsyncRegionalAccessBoundaryRefreshManager() ) with mock.patch.object( - _regional_access_boundary_utils._LOGGER, "warning" - ) as mock_warning: + _regional_access_boundary_utils._LOGGER, "info" + ) as mock_info: manager.start_refresh(credentials, request, rab_manager) await manager._worker_task - mock_warning.assert_not_called() + mock_info.assert_called_once() + assert "lookup raised an exception" in mock_info.call_args[0][0] rab_manager.process_regional_access_boundary_info.assert_called_once_with(None) From ff169aa5dbcd98c282de013177a904e5c53421e0 Mon Sep 17 00:00:00 2001 From: nbayati <99771966+nbayati@users.noreply.github.com> Date: Thu, 25 Jun 2026 09:33:22 -0700 Subject: [PATCH 3/5] refactor(auth): lower RAB lookup log to DEBUG --- .../auth/_regional_access_boundary_utils.py | 20 +++++++++---------- .../google/auth/compute_engine/credentials.py | 2 +- .../google-auth/google/auth/credentials.py | 2 +- packages/google-auth/google/oauth2/_client.py | 2 +- .../google/oauth2/_client_async.py | 2 +- .../test__regional_access_boundary_utils.py | 4 +++- .../test__regional_access_boundary_utils.py | 8 ++++---- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/google-auth/google/auth/_regional_access_boundary_utils.py b/packages/google-auth/google/auth/_regional_access_boundary_utils.py index 90d8f2484161..d09c5f0ff016 100644 --- a/packages/google-auth/google/auth/_regional_access_boundary_utils.py +++ b/packages/google-auth/google/auth/_regional_access_boundary_utils.py @@ -219,7 +219,7 @@ def start_blocking_refresh(self, credentials, request): """ # Async credentials do not support blocking lookups. if inspect.iscoroutinefunction(credentials._lookup_regional_access_boundary): - _LOGGER.info( + _LOGGER.debug( "Blocking Regional Access Boundary lookup is not supported for async credentials." ) self.process_regional_access_boundary_info(None) @@ -233,7 +233,7 @@ def start_blocking_refresh(self, credentials, request): credentials._lookup_regional_access_boundary(request, fail_fast=True) ) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Blocking Regional Access Boundary lookup raised an exception: %s", e, exc_info=True, @@ -263,7 +263,7 @@ async def start_blocking_refresh_async(self, credentials, request): ) ) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Regional Access Boundary lookup raised an exception: %s", e, exc_info=True, @@ -294,10 +294,10 @@ def process_regional_access_boundary_info(self, regional_access_boundary_info): cooldown_expiry=None, cooldown_duration=DEFAULT_REGIONAL_ACCESS_BOUNDARY_COOLDOWN, ) - _LOGGER.info("Regional Access Boundary lookup successful.") + _LOGGER.debug("Regional Access Boundary lookup successful.") else: # On failure, calculate cooldown and update state. - _LOGGER.info( + _LOGGER.debug( "Regional Access Boundary lookup failed. Entering cooldown." ) @@ -362,7 +362,7 @@ def run(self): self._credentials._lookup_regional_access_boundary(self._request) ) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Asynchronous Regional Access Boundary lookup raised an exception: %s", e, exc_info=True, @@ -413,7 +413,7 @@ def start_refresh(self, credentials, request, rab_manager): try: copied_request = copy.deepcopy(request) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Could not deepcopy transport for background RAB refresh. " "Skipping background refresh to avoid thread safety issues. " "Exception: %s", @@ -473,7 +473,7 @@ async def _close_cloned_request(lookup_request, is_cloned): await maybe_coro except Exception as e: adapter_type = " asynchronous " if is_async else " " - _LOGGER.info( + _LOGGER.debug( "Failed to cleanly close cloned%srequest transport: %s", adapter_type, e, @@ -524,7 +524,7 @@ def start_refresh(self, credentials, request, rab_manager): is_cloned, ) = _prepare_async_lookup_callable(request) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Synchronous cloning of request for Regional Access Boundary lookup failed: %s", e, exc_info=True, @@ -540,7 +540,7 @@ async def _worker(): ) ) except Exception as e: - _LOGGER.info( + _LOGGER.debug( "Asynchronous Regional Access Boundary lookup raised an exception: %s", e, exc_info=True, diff --git a/packages/google-auth/google/auth/compute_engine/credentials.py b/packages/google-auth/google/auth/compute_engine/credentials.py index ffe62e0ba9af..3701751bda2b 100644 --- a/packages/google-auth/google/auth/compute_engine/credentials.py +++ b/packages/google-auth/google/auth/compute_engine/credentials.py @@ -219,7 +219,7 @@ def _build_regional_access_boundary_lookup_url( return None if not _metadata._is_service_account_email(self.service_account_email): - _LOGGER.info( + _LOGGER.debug( "Service account email '%s' is not a valid email. Skipping Regional Access Boundary lookup.", self.service_account_email, ) diff --git a/packages/google-auth/google/auth/credentials.py b/packages/google-auth/google/auth/credentials.py index 0c7bc400099f..3975dab48ad4 100644 --- a/packages/google-auth/google/auth/credentials.py +++ b/packages/google-auth/google/auth/credentials.py @@ -535,7 +535,7 @@ def _lookup_regional_access_boundary( url = self._build_regional_access_boundary_lookup_url(request=request) if not url: - _LOGGER.info("Failed to build Regional Access Boundary lookup URL.") + _LOGGER.debug("Failed to build Regional Access Boundary lookup URL.") return None headers: Dict[str, str] = {} diff --git a/packages/google-auth/google/oauth2/_client.py b/packages/google-auth/google/oauth2/_client.py index f79fcd672bf7..464849e4f3e0 100644 --- a/packages/google-auth/google/oauth2/_client.py +++ b/packages/google-auth/google/oauth2/_client.py @@ -582,7 +582,7 @@ def _lookup_regional_access_boundary_request( request, url, can_retry=can_retry, headers=headers, fail_fast=fail_fast ) if not response_status_ok: - _LOGGER.info( + _LOGGER.debug( "Regional Access Boundary HTTP request failed after retries: response_data=%s, retryable_error=%s", response_data, retryable_error, diff --git a/packages/google-auth/google/oauth2/_client_async.py b/packages/google-auth/google/oauth2/_client_async.py index 67ed09ab2a23..6e921d23f9aa 100644 --- a/packages/google-auth/google/oauth2/_client_async.py +++ b/packages/google-auth/google/oauth2/_client_async.py @@ -356,7 +356,7 @@ async def _lookup_regional_access_boundary_request( request, url, can_retry=can_retry, headers=headers, fail_fast=fail_fast ) if not response_status_ok: - client._LOGGER.info( + client._LOGGER.debug( "Regional Access Boundary HTTP request failed after retries: response_data=%s, retryable_error=%s", response_data, retryable_error, diff --git a/packages/google-auth/tests/test__regional_access_boundary_utils.py b/packages/google-auth/tests/test__regional_access_boundary_utils.py index 201976c2741d..d7a7ff13f027 100644 --- a/packages/google-auth/tests/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests/test__regional_access_boundary_utils.py @@ -29,7 +29,9 @@ def rab_caplog(caplog): """Fixture to configure logging capture and ensure propagation for RAB utilities.""" - caplog.set_level(logging.INFO, logger="google.auth._regional_access_boundary_utils") + caplog.set_level( + logging.DEBUG, logger="google.auth._regional_access_boundary_utils" + ) google_logger = logging.getLogger("google") original_propagate = google_logger.propagate diff --git a/packages/google-auth/tests_async/test__regional_access_boundary_utils.py b/packages/google-auth/tests_async/test__regional_access_boundary_utils.py index 4c6c9bd034aa..af8e17c6403c 100644 --- a/packages/google-auth/tests_async/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests_async/test__regional_access_boundary_utils.py @@ -208,13 +208,13 @@ async def test_async_worker_exception_logging(): ) with mock.patch.object( - _regional_access_boundary_utils._LOGGER, "info" - ) as mock_info: + _regional_access_boundary_utils._LOGGER, "debug" + ) as mock_debug: manager.start_refresh(credentials, request, rab_manager) await manager._worker_task - mock_info.assert_called_once() - assert "lookup raised an exception" in mock_info.call_args[0][0] + mock_debug.assert_called_once() + assert "lookup raised an exception" in mock_debug.call_args[0][0] rab_manager.process_regional_access_boundary_info.assert_called_once_with(None) From fad1e4a95a1ca2197c8129e17d588adbf02a428f Mon Sep 17 00:00:00 2001 From: nbayati <99771966+nbayati@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:14:55 -0700 Subject: [PATCH 4/5] fix unit tests --- .../test__regional_access_boundary_utils.py | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/google-auth/tests/test__regional_access_boundary_utils.py b/packages/google-auth/tests/test__regional_access_boundary_utils.py index d7a7ff13f027..189733787fdd 100644 --- a/packages/google-auth/tests/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests/test__regional_access_boundary_utils.py @@ -414,13 +414,12 @@ def test_lookup_regional_access_boundary_failure(self, mock_lookup_rab, rab_capl assert rab_manager._data.expiry is None assert rab_manager._data.cooldown_expiry is not None - assert ( - "Regional Access Boundary lookup failed. Entering cooldown." - in rab_caplog.text + # RAB failures should be logged at DEBUG level. + assert any( + t[1] == logging.DEBUG + and "Regional Access Boundary lookup failed. Entering cooldown." in t[2] + for t in rab_caplog.record_tuples ) - # RAB failures should be logged at INFO level. - warning_logs = [t for t in rab_caplog.record_tuples if t[1] == logging.WARNING] - assert not warning_logs, f"Unexpected warnings emitted: {warning_logs}" def test_lookup_regional_access_boundary_null_url(self): creds = oauth2_credentials.Credentials(token="token") @@ -494,17 +493,17 @@ def test_regional_access_boundary_refresh_thread_run_failure( assert rab_manager._data.cooldown_expiry == expected_cooldown_expiry assert rab_manager._data.cooldown_duration == initial_cooldown * 2 - assert ( - "Asynchronous Regional Access Boundary lookup raised an exception" - in rab_caplog.text + # RAB failures should be logged at DEBUG level. + assert any( + t[1] == logging.DEBUG + and "Asynchronous Regional Access Boundary lookup raised an exception" in t[2] + for t in rab_caplog.record_tuples ) - assert ( - "Regional Access Boundary lookup failed. Entering cooldown." - in rab_caplog.text + assert any( + t[1] == logging.DEBUG + and "Regional Access Boundary lookup failed. Entering cooldown." in t[2] + for t in rab_caplog.record_tuples ) - # RAB failures should be logged at INFO level. - warning_logs = [t for t in rab_caplog.record_tuples if t[1] == logging.WARNING] - assert not warning_logs, f"Unexpected warnings emitted: {warning_logs}" @mock.patch("google.auth._helpers.utcnow") def test_regional_access_boundary_refresh_thread_run_failure_hard_expiry( From 23bc0ca19b9b3d215808988b0a8ecd795b580e61 Mon Sep 17 00:00:00 2001 From: nbayati <99771966+nbayati@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:50:52 -0700 Subject: [PATCH 5/5] fix lint issue --- .../google-auth/tests/test__regional_access_boundary_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/google-auth/tests/test__regional_access_boundary_utils.py b/packages/google-auth/tests/test__regional_access_boundary_utils.py index 189733787fdd..04fc5928ea83 100644 --- a/packages/google-auth/tests/test__regional_access_boundary_utils.py +++ b/packages/google-auth/tests/test__regional_access_boundary_utils.py @@ -496,7 +496,8 @@ def test_regional_access_boundary_refresh_thread_run_failure( # RAB failures should be logged at DEBUG level. assert any( t[1] == logging.DEBUG - and "Asynchronous Regional Access Boundary lookup raised an exception" in t[2] + and "Asynchronous Regional Access Boundary lookup raised an exception" + in t[2] for t in rab_caplog.record_tuples ) assert any(