def testSetUserProperty(self):
     acl = self.folder.acl_users
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assertTrue(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     self.assertEqual(mgr_ob.getProperty('sn'), manager_user.get('sn'))
     acl.manage_setUserProperty(mgr_ob.getUserDN(), 'sn', 'NewLastName')
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual(mgr_ob.getProperty('sn'), 'NewLastName')
 def testSetUserPropertyMultivalueHandling(self):
     acl = self.folder.acl_users
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty("_login_attr")))
     self.assertNotEqual(mgr_ob, None)
     self.assertEqual(mgr_ob.getProperty("sn"), manager_user.get("sn"))
     acl.manage_setUserProperty(mgr_ob.getUserDN(), "sn", "NewLastName; Secondlastname")
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty("_login_attr")))
     self.assertEqual(mgr_ob.getProperty("sn"), "NewLastName; Secondlastname")
 def testManageEditUserBinaryHandling(self):
     # Make sure binary attributes are never converted
     test_home = package_home(globals())
     image_path = os.path.join(test_home, "test.jpg")
     image_file = open(image_path, "rb")
     image_contents = image_file.read()
     image_file.close()
     acl = self.folder.acl_users
     acl.manage_addLDAPSchemaItem("jpegPhoto", binary=True)
     acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty("_login_attr")))
     self.assertEqual(mgr_ob.getProperty("jpegPhoto"), "")
     acl.manage_editUser(mgr_ob.getUserDN(), kwargs={"jpegPhoto": image_contents})
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty("_login_attr")))
     self.assertEqual(mgr_ob.getProperty("jpegPhoto"), image_contents)
 def testModRDN(self):
     acl = self.folder.acl_users
     ae = self.assertEqual
     for role in ug('user_roles'):
         acl.manage_addGroup(role)
         acl.manage_addGroupMapping(role, role)
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     newSecurityManager({}, mgr_ob)
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     self.assert_(not msg)
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertNotEqual(user_ob, None)
     user_dn = user_ob.getUserDN()
     msg = acl.manage_editUser(user_dn, kwargs={'cn' : 'new'})
     user_ob = acl.getUser('new')
     ae(user_ob.getProperty('cn'), 'new')
     ae(user_ob.getId(), 'new')
     new_dn = 'cn=new,%s' % acl.getProperty('users_base')
     ae(user_ob.getUserDN(), new_dn)
     for role in ug('user_roles'):
         self.assert_(role in user_ob.getRoles())
     for role in acl.getProperty('_roles'):
         self.assert_(role in user_ob.getRoles())
     noSecurityManager()
 def testManageEditUserBinaryHandling(self):
     # Make sure binary attributes are never converted
     test_home = package_home(globals())
     image_path = os.path.join(test_home, 'test.jpg')
     image_file = open(image_path, 'rb')
     image_contents = image_file.read()
     image_file.close()
     acl = self.folder.acl_users
     acl.manage_addLDAPSchemaItem('jpegPhoto', binary=True)
     acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual(mgr_ob.getProperty('jpegPhoto'), '')
     acl.manage_editUser(mgr_ob.getUserDN(),
                         kwargs={'jpegPhoto': image_contents})
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual(mgr_ob.getProperty('jpegPhoto'), image_contents)
 def testModRDN(self):
     acl = self.folder.acl_users
     ae = self.assertEqual
     for role in ug('user_roles'):
         acl.manage_addGroup(role)
         acl.manage_addGroupMapping(role, role)
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     newSecurityManager({}, mgr_ob)
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     self.assert_(not msg)
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertNotEqual(user_ob, None)
     user_dn = user_ob.getUserDN()
     msg = acl.manage_editUser(user_dn, kwargs={'cn': 'new'})
     user_ob = acl.getUser('new')
     ae(user_ob.getProperty('cn'), 'new')
     ae(user_ob.getId(), 'new')
     new_dn = 'cn=new,%s' % acl.getProperty('users_base')
     ae(user_ob.getUserDN(), new_dn)
     for role in ug('user_roles'):
         self.assert_(role in user_ob.getRoles())
     for role in acl.getProperty('_roles'):
         self.assert_(role in user_ob.getRoles())
     noSecurityManager()
 def testModRDN(self):
     acl = self.folder.acl_users
     ae = self.assertEqual
     for role in ug("user_roles"):
         acl.manage_addGroup(role)
         acl.manage_addGroupMapping(role, role)
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty("_login_attr")))
     self.assertNotEqual(mgr_ob, None)
     newSecurityManager({}, mgr_ob)
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     self.assert_(not msg)
     user_ob = acl.getUser(ug(acl.getProperty("_login_attr")))
     self.assertNotEqual(user_ob, None)
     user_dn = user_ob.getUserDN()
     msg = acl.manage_editUser(user_dn, kwargs={"cn": "new"})
     user_ob = acl.getUser("new")
     ae(user_ob.getProperty("cn"), "new")
     ae(user_ob.getId(), "new")
     new_dn = "cn=new,%s" % acl.getProperty("users_base")
     ae(user_ob.getUserDN(), new_dn)
     for role in ug("user_roles"):
         self.assert_(role in user_ob.getRoles())
     for role in acl.getProperty("_roles"):
         self.assert_(role in user_ob.getRoles())
     noSecurityManager()
 def testSetUserPropertyBinaryHandling(self):
     # Make sure binary attributes are never converted
     test_home = package_home(globals())
     image_path = os.path.join(test_home, 'test.jpg')
     image_file = open(image_path, 'rb')
     image_contents = image_file.read()
     image_file.close()
     acl = self.folder.acl_users
     acl.manage_addLDAPSchemaItem('jpegPhoto', binary=True)
     acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual(mgr_ob.getProperty('jpegPhoto'), '')
     acl.manage_setUserProperty( mgr_ob.getUserDN()
                               , 'jpegPhoto'
                               , image_contents
                               )
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual(mgr_ob.getProperty('jpegPhoto'), image_contents)
 def testSetUserProperty(self):
     acl = self.folder.acl_users
     ae = self.assertEqual
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     self.assertEqual( mgr_ob.getProperty('sn')
                     , manager_user.get('sn')
                     )
     acl.manage_setUserProperty( mgr_ob.getUserDN()
                               , 'sn'
                               , 'NewLastName'
                               )
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertEqual( mgr_ob.getProperty('sn')
                     , 'NewLastName'
                     )
 def testDeleteUser(self):
     acl = self.folder.acl_users
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     self.assert_(not msg)
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     newSecurityManager({}, mgr_ob)
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertNotEqual(user_ob, None)
     user_dn = user_ob.getUserDN()
     acl.manage_deleteUsers([user_dn])
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertEqual(user_ob, None)
     self.assertEqual(acl.getGroups(dn=user_dn), [])
     noSecurityManager()
 def testDeleteUser(self):
     acl = self.folder.acl_users
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     self.assert_(not msg)
     msg = acl.manage_addUser(REQUEST=None, kwargs=manager_user)
     self.assert_(not msg)
     mgr_ob = acl.getUser(manager_user.get(acl.getProperty('_login_attr')))
     self.assertNotEqual(mgr_ob, None)
     newSecurityManager({}, mgr_ob)
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertNotEqual(user_ob, None)
     user_dn = user_ob.getUserDN()
     acl.manage_deleteUsers([user_dn])
     user_ob = acl.getUser(ug(acl.getProperty('_login_attr')))
     self.assertEqual(user_ob, None)
     self.assertEqual(acl.getGroups(dn=user_dn), [])
     noSecurityManager()