From b4e7986ad816e4677ef9ea686ad20e7cdeb506a0 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Tue, 24 Jun 2025 10:56:35 -0700 Subject: [PATCH 1/2] Remove useless _is_running_in_desktop This was introiduced by #811 and tweaked in shotgunsoftware/tk-framework-desktopstartup#71 but I believe this is no longer useful since we now have an authentication UI selector --- python/tank/authentication/login_dialog.py | 16 +--------- .../test_interactive_authentication.py | 31 ------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/python/tank/authentication/login_dialog.py b/python/tank/authentication/login_dialog.py index fd24529620..1dfac7e595 100644 --- a/python/tank/authentication/login_dialog.py +++ b/python/tank/authentication/login_dialog.py @@ -69,19 +69,6 @@ # request thread. THREAD_WAIT_TIMEOUT_MS = 5000 - -def _is_running_in_desktop(): - """ - Indicate if we are in the context of the PTR desktop app. - - When the PTR desktop app is used, we want to disregard the value returned - by the call to `get_shotgun_authenticator_support_web_login()` when the - target site is using Autodesk Identity. - """ - executable_name = os.path.splitext(os.path.basename(sys.executable))[0].lower() - return executable_name in ["shotgun", "shotgrid"] - - class QuerySiteAndUpdateUITask(QtCore.QThread): """ This class uses a different thread to query the site's information and find @@ -493,8 +480,7 @@ def _toggle_web(self, method_selected=None): if os.environ.get("SGTK_FORCE_STANDARD_LOGIN_DIALOG"): logger.info("Using the standard login dialog with the Flow Production Tracking") else: - if _is_running_in_desktop(): - can_use_web = can_use_web or self.site_info.autodesk_identity_enabled + can_use_web = can_use_web or self.site_info.autodesk_identity_enabled # If we have full support for Web-based login, or if we enable it in our # environment, use the Unified Login Flow for all authentication modes. diff --git a/tests/authentication_tests/test_interactive_authentication.py b/tests/authentication_tests/test_interactive_authentication.py index 3fce6dcca4..9a67e799a8 100644 --- a/tests/authentication_tests/test_interactive_authentication.py +++ b/tests/authentication_tests/test_interactive_authentication.py @@ -518,10 +518,6 @@ def test_ui_auth_with_whitespace(self): "tank.authentication.site_info._get_site_infos", return_value={}, ) - @mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, - ) def test_ui_error_management(self, *unused_mocks): # Empty of invalid site with self._login_dialog() as ld: @@ -635,10 +631,6 @@ def test_login_dialog_exit_confirmation(self): self.assertEqual(ld.isVisible(), False) @suppress_generated_code_qt_warnings - @mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, - ) @mock.patch( "tank.authentication.web_login_support.get_shotgun_authenticator_support_web_login", return_value=True, @@ -778,10 +770,6 @@ def test_ui_auth_2fa(self, *mocks): ) @suppress_generated_code_qt_warnings - @mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, - ) @mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=True, @@ -834,9 +822,6 @@ def test_web_login_not_supported(self): with mock.patch( "tank.authentication.login_dialog.ASL_AuthTask.start" - ), mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=False, @@ -858,9 +843,6 @@ def test_web_login_not_supported(self): def test_login_dialog_method_selected_default(self): with mock.patch( "tank.authentication.login_dialog.ASL_AuthTask.start" - ), mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=True, @@ -932,9 +914,6 @@ def test_login_dialog_method_selected_default(self): { "SGTK_DEFAULT_AUTH_METHOD": "qt_web_login", }, - ), mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=False, ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=False, @@ -965,9 +944,6 @@ def test_login_dialog_method_selected_default(self): def test_login_dialog_method_selected_session_cache(self): with mock.patch( "tank.authentication.login_dialog.ASL_AuthTask.start" - ), mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=True, @@ -995,9 +971,6 @@ def test_login_dialog_method_selected_session_cache(self): # qt_web_login but method is not available with mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=False, - ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=False, ), mock.patch( @@ -1015,10 +988,6 @@ def test_login_dialog_method_selected_session_cache(self): @suppress_generated_code_qt_warnings @mock.patch("tank.authentication.login_dialog.ASL_AuthTask.start") - @mock.patch( - "tank.authentication.login_dialog._is_running_in_desktop", - return_value=True, - ) @mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=True, From e6481241a9077d2fe4fd4341790afbb1ced4d689 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 25 Jun 2025 08:39:39 -0700 Subject: [PATCH 2/2] Fixup tests --- .../test_interactive_authentication.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/authentication_tests/test_interactive_authentication.py b/tests/authentication_tests/test_interactive_authentication.py index 9a67e799a8..c85aab9521 100644 --- a/tests/authentication_tests/test_interactive_authentication.py +++ b/tests/authentication_tests/test_interactive_authentication.py @@ -917,6 +917,13 @@ def test_login_dialog_method_selected_default(self): ), mock.patch( "tank.authentication.login_dialog.get_shotgun_authenticator_support_web_login", return_value=False, + ), mock.patch( + "tank.authentication.site_info._get_site_infos", + return_value={ + "user_authentication_method": "default", + "unified_login_flow_enabled": True, + "authentication_app_session_launcher_enabled": True, + }, ), self._login_dialog( hostname="https://host.shotgunstudio.com", ) as ld: @@ -950,7 +957,7 @@ def test_login_dialog_method_selected_session_cache(self): ), mock.patch( "tank.authentication.site_info._get_site_infos", return_value={ - "user_authentication_method": "oxygen", + "user_authentication_method": "default", "unified_login_flow_enabled": True, "authentication_app_session_launcher_enabled": True, },