From 2f73cfde1866525758b65652c7c420c8dfdd8d3c Mon Sep 17 00:00:00 2001 From: "Xiang (Sean) Zhou" Date: Tue, 29 Jul 2025 13:13:58 -0700 Subject: [PATCH] chore: Fix the long running test cases The test test_token_exchange_not_supported was slow because of an incorrect monkeypatch target. The test was patching google.adk.auth.auth_handler.AUTHLIB_AVAILABLE, but the actual OAuth2 exchange logic uses a different AUTHLIB_AVAILABLE variable in google.adk.auth.exchanger.oauth2_credential_exchanger. What was happening: Test set auth_handler.AUTHLIB_AVAILABLE = False AuthHandler.exchange_auth_token() called OAuth2CredentialExchanger.exchange() But oauth2_credential_exchanger.AUTHLIB_AVAILABLE was still True The exchanger attempted real OAuth2 token exchange with client.fetch_token() This made actual network calls to OAuth2 endpoints, causing timeouts and delays PiperOrigin-RevId: 788576949 --- tests/unittests/auth/test_auth_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unittests/auth/test_auth_handler.py b/tests/unittests/auth/test_auth_handler.py index 20a3f8e4..2a65f779 100644 --- a/tests/unittests/auth/test_auth_handler.py +++ b/tests/unittests/auth/test_auth_handler.py @@ -456,7 +456,10 @@ class TestExchangeAuthToken: self, auth_config_with_auth_code, monkeypatch ): """Test when token exchange is not supported.""" - monkeypatch.setattr("google.adk.auth.auth_handler.AUTHLIB_AVAILABLE", False) + monkeypatch.setattr( + "google.adk.auth.exchanger.oauth2_credential_exchanger.AUTHLIB_AVAILABLE", + False, + ) handler = AuthHandler(auth_config_with_auth_code) result = await handler.exchange_auth_token()