From ebf535fede8cbcffabc9280bc1fd952954beec81 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Tue, 2 Jan 2024 14:27:55 -0600 Subject: [PATCH] Update to SDK v3.34.0 This version of the SDK deprecates `oauth2_validate_token`, so the change replaces it with a direct form-encoded POST in order to maintain the exact same behavior in the CLI for now. --- setup.py | 2 +- src/globus_cli/login_manager/manager.py | 4 +++- tests/functional/test_login_command.py | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 6eb22d3b2..dd1a5caef 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def read_readme(): package_dir={"": "src"}, python_requires=">=3.7", install_requires=[ - "globus-sdk==3.33.0", + "globus-sdk==3.34.0", "click>=8.1.4,<9", "jmespath==1.0.1", "packaging>=17.0", diff --git a/src/globus_cli/login_manager/manager.py b/src/globus_cli/login_manager/manager.py index c17489630..025f766f9 100644 --- a/src/globus_cli/login_manager/manager.py +++ b/src/globus_cli/login_manager/manager.py @@ -87,7 +87,9 @@ def is_logged_in(self) -> bool: def _validate_token(self, token: str) -> bool: auth_client = internal_auth_client() try: - res = auth_client.oauth2_validate_token(token) + res = auth_client.post( + "/v2/oauth2/token/validate", data={"token": token}, encoding="form" + ) # if the instance client is invalid, an AuthAPIError will be raised except globus_sdk.AuthAPIError: return False diff --git a/tests/functional/test_login_command.py b/tests/functional/test_login_command.py index 42f3c5da6..1a3ab86fe 100644 --- a/tests/functional/test_login_command.py +++ b/tests/functional/test_login_command.py @@ -20,7 +20,7 @@ def test_login_validates_token( disable_login_manager_validate_token.undo() with mock.patch("globus_cli.login_manager.manager.internal_auth_client") as m: - ac = mock.MagicMock(spec=globus_sdk.NativeAppAuthClient) + ac = mock.MagicMock(spec=globus_sdk.ConfidentialAppAuthClient) m.return_value = ac run_line("globus login") @@ -28,8 +28,12 @@ def test_login_validates_token( by_rs = mock_login_token_response.by_resource_server a_rt = by_rs["auth.globus.org"]["refresh_token"] t_rt = by_rs["transfer.api.globus.org"]["refresh_token"] - ac.oauth2_validate_token.assert_any_call(a_rt) - ac.oauth2_validate_token.assert_any_call(t_rt) + ac.post.assert_any_call( + "/v2/oauth2/token/validate", data={"token": a_rt}, encoding="form" + ) + ac.post.assert_any_call( + "/v2/oauth2/token/validate", data={"token": t_rt}, encoding="form" + ) class MockToken: