Skip to content

Commit

Permalink
fix test sudo_as_login
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-delaporte committed Nov 2, 2020
1 parent cbff75a commit 152d495
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 3 additions & 1 deletion python/tank/authentication/shotgun_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def create_session_user(
return user.ShotgunWebUser(impl)
return user.ShotgunUser(impl)

def create_script_user(self, api_script, api_key, host=None, http_proxy=None, sudo_as_login=None):
def create_script_user(
self, api_script, api_key, host=None, http_proxy=None, sudo_as_login=None
):
"""
Create an AuthenticatedUser given a set of script credentials.
Expand Down
10 changes: 8 additions & 2 deletions python/tank/authentication/user_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,14 @@ def __repr__(self):
:returns: A string containing script name and site.
"""
sudo_as_login_repr = " (as %s)" % self._sudo_as_login if self._sudo_as_login else ""
return "<ScriptUser %s%s @ %s>" % (self._api_script, sudo_as_login_repr, self._host)
sudo_as_login_repr = (
" (as %s)" % self._sudo_as_login if self._sudo_as_login else ""
)
return "<ScriptUser %s%s @ %s>" % (
self._api_script,
sudo_as_login_repr,
self._host,
)

def __str__(self):
"""
Expand Down
16 changes: 16 additions & 0 deletions tests/authentication_tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def _create_script_user(self):
api_script="api_script",
api_key="api_key",
http_proxy="http_proxy",
sudo_as_login=None,
)
)

def _create_script_sudo_as_login_user(self):
return user.ShotgunUser(
user_impl.ScriptUser(
host="host",
api_script="api_script",
api_key="api_key",
http_proxy="http_proxy",
sudo_as_login="sudo_as_login",
)
)

Expand Down Expand Up @@ -96,6 +108,10 @@ def test_login_value(self):
script_user = self._create_script_user()
self.assertIsNone(script_user.login)

sudo_user = self._create_script_sudo_as_login_user()
self.assertEqual(sudo_user.login, "sudo_as_login")
self.assertEqual(sudo_user.sudo_as_login, "sudo_as_login")

class CustomUser(user_impl.ShotgunUserImpl):
def __init__(self):
super(CustomUser, self).__init__("https://test.shotgunstudio.com", None)
Expand Down

0 comments on commit 152d495

Please sign in to comment.