Skip to content

SG-38266 Remove useless _is_running_in_desktop #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions python/tank/authentication/login_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
40 changes: 8 additions & 32 deletions tests/authentication_tests/test_interactive_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -932,12 +914,16 @@ 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,
), 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:
Expand Down Expand Up @@ -965,16 +951,13 @@ 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,
), 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,
},
Expand All @@ -995,9 +978,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(
Expand All @@ -1015,10 +995,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,
Expand Down