Commit a868860f authored by Jérome Perrin's avatar Jérome Perrin

core: new Base_getLoginValueByUserName script

parent b8dc32ba
# Proxy roles: Manager to access searchUsers
if REQUEST is not None:
return
login_path_set = {login['path'] for login in sum([
user['login_list'] for user in context.acl_users.searchUsers(
login=user_name,
exact_match=True,
) if 'login_list' in user], []) }
if login_path_set:
login_path, = login_path_set
return context.getPortalObject().restrictedTraverse(login_path)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>user_name, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getLoginValueByUserName</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -633,6 +633,20 @@ class TestUserManagement(ERP5TypeTestCase):
self.assertEqual(None, self.portal.Base_getUserValueByUserId("not a user_id"))
def test_Base_getLoginValueByUserName(self):
user_id1, login1, _ = self._makePerson()
user_id2, login2, _ = self._makePerson()
login_value1 = self.portal.Base_getLoginValueByUserName(login1)
self.assertEqual('Person', login_value1.getPortalType())
self.assertEqual(login1, login_value1.getReference())
login_value2 = self.portal.Base_getLoginValueByUserName(login2)
self.assertEqual('Person', login_value2.getPortalType())
self.assertEqual(login2, login_value2.getReference())
self.assertEqual(None, self.portal.Base_getLoginValueByUserName("not a login"))
class TestUserManagementExternalAuthentication(TestUserManagement):
def getTitle(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment