Skip to content

Commit 2f73cfd

Browse files
seanzhougooglecopybara-github
authored andcommitted
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
1 parent ec8dd57 commit 2f73cfd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/unittests/auth/test_auth_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,10 @@ async def test_token_exchange_not_supported(
456456
self, auth_config_with_auth_code, monkeypatch
457457
):
458458
"""Test when token exchange is not supported."""
459-
monkeypatch.setattr("google.adk.auth.auth_handler.AUTHLIB_AVAILABLE", False)
459+
monkeypatch.setattr(
460+
"google.adk.auth.exchanger.oauth2_credential_exchanger.AUTHLIB_AVAILABLE",
461+
False,
462+
)
460463

461464
handler = AuthHandler(auth_config_with_auth_code)
462465
result = await handler.exchange_auth_token()

0 commit comments

Comments
 (0)