def test_002_user_recipient_policy_duplicate(self): from tests.functional.user_add import user_add user = { 'local': 'jane.doe', 'domain': 'example.org' } user_add("Jane", "Doe") time.sleep(3) auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (user)) if hasattr(self, 'assertIsInstance'): self.assertIsInstance(recipient, str) self.assertEqual(recipient, "uid=doe2,ou=People,dc=example,dc=org") result = wap_client.user_info(recipient) if not result.has_key('mailhost'): from tests.functional.synchronize import synchronize_once synchronize_once() result = wap_client.user_info(recipient) self.assertEqual(result['mail'], '*****@*****.**') self.assertEqual(result['alias'], ['*****@*****.**', '*****@*****.**'])
def test_002_user_recipient_policy_duplicate(self): from tests.functional.user_add import user_add user = {'local': 'jane.doe', 'domain': 'example.org'} user_add("Jane", "Doe") time.sleep(3) auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (user)) if hasattr(self, 'assertIsInstance'): self.assertIsInstance(recipient, str) self.assertEqual(recipient, "uid=doe2,ou=People,dc=example,dc=org") result = wap_client.user_info(recipient) if 'mailhost' not in result: from tests.functional.synchronize import synchronize_once synchronize_once() result = wap_client.user_info(recipient) self.assertEqual(result['mail'], '*****@*****.**') self.assertEqual(result['alias'], ['*****@*****.**', '*****@*****.**'])
def test_001_user_rename(self): """ Rename user "Doe, John" to "Sixpack, Joe" and verify the recipient policy is applied, and the IMAP INBOX folder for the user is renamed. """ auth = Auth() auth.connect() recipient = auth.find_recipient('*****@*****.**') user_info = wap_client.user_info(recipient) if not user_info.has_key('mailhost'): from tests.functional.synchronize import synchronize_once synchronize_once() imap = IMAP() imap.connect() folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 1) auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) user_info = wap_client.user_info(recipient) user_info['sn'] = 'Sixpack' user_info['givenname'] = 'Joe' user_info['uid'] = 'sixpack' user_edit = wap_client.user_edit(recipient, user_info) time.sleep(2) print imap.lm() user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') if not user_info['mail'] == '*****@*****.**': from tests.functional.synchronize import synchronize_once synchronize_once() user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') self.assertEqual(user_info['mail'], '*****@*****.**') print imap.lm() folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 0, "INBOX for john.doe still exists") folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
def test_001_user_rename(self): """ Rename user "Doe, John" to "Sixpack, Joe" and verify the recipient policy is applied, and the IMAP INBOX folder for the user is renamed. """ auth = Auth() auth.connect() recipient = auth.find_recipient('*****@*****.**') user_info = wap_client.user_info(recipient) if 'mailhost' not in user_info: from tests.functional.synchronize import synchronize_once synchronize_once() imap = IMAP() imap.connect() folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 1) auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) user_info = wap_client.user_info(recipient) user_info['sn'] = 'Sixpack' user_info['givenname'] = 'Joe' user_info['uid'] = 'sixpack' user_edit = wap_client.user_edit(recipient, user_info) time.sleep(2) print imap.lm() user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') if not user_info['mail'] == '*****@*****.**': from tests.functional.synchronize import synchronize_once synchronize_once() user_info = wap_client.user_info('uid=sixpack,ou=People,dc=example,dc=org') self.assertEqual(user_info['mail'], '*****@*****.**') print imap.lm() folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 0, "INBOX for john.doe still exists") folders = imap.lm('user/[email protected]') self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
def teardown_class(self): time.sleep(2) res_attr = conf.get('cyrus-sasl', 'result_attribute') exec("ac_folders = %s" % (conf.get_raw(conf.get('kolab', 'primary_domain'), 'autocreate_folders'))) expected_number_of_folders = len(ac_folders.keys()) + 1 users = [] result = wap_client.users_list() for user in result['list'].keys(): user_info = wap_client.user_info(user) users.append(user_info) result = wap_client.user_delete({'user': user}) imap = IMAP() imap.connect() for user in users: if len(user[res_attr].split('@')) > 1: localpart = user[res_attr].split('@')[0] domain = user[res_attr].split('@')[1] folders = [] folders.extend(imap.lm('user/%s' % (user[res_attr]))) folders.extend(imap.lm('user/%s/*@%s' % (localpart,domain)))
def test_002_fr_FR_user_recipient_policy(self): auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) if hasattr(self, 'assertIsInstance'): self.assertIsInstance(recipient, str) self.assertEqual(recipient, "uid=fuentes,ou=People,dc=example,dc=org") result = wap_client.user_info(recipient) self.assertEqual(result['mail'], '*****@*****.**') self.assertEqual(sorted(result['alias']), ['*****@*****.**', '*****@*****.**'])
def test_001_user_recipient_policy(self): auth = Auth() auth.connect() recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user)) if hasattr(self, 'assertIsInstance'): self.assertIsInstance(recipient, str) self.assertEqual(recipient, "uid=doe,ou=People,dc=example,dc=org") result = wap_client.user_info(recipient) self.assertEqual(result['mail'], '*****@*****.**') self.assertEqual(result['alias'], ['*****@*****.**', '*****@*****.**'])
def test_001_default(self): from tests.functional.user_add import user_add user_add("John", "Doe") from tests.functional.synchronize import synchronize_once synchronize_once() auth = Auth() auth.connect() user = auth.find_recipient('*****@*****.**') user_info = wap_client.user_info(user) self.assertEqual(user_info['uid'], "doe") from tests.functional.purge_users import purge_users purge_users()
def test_003_givenname_fc_dot_surname(self): self.set('example.org', 'policy_uid', "'%(givenname)s'[0:1].%(surname)s") from tests.functional.user_add import user_add user_add("John", "Doe") from tests.functional.synchronize import synchronize_once synchronize_once() auth = Auth() auth.connect() user = auth.find_recipient('*****@*****.**') user_info = wap_client.user_info(user) self.assertEqual(user_info['uid'], "J.Doe") from tests.functional.purge_users import purge_users purge_users()
# import commands import pykolab from pykolab import utils from pykolab.translate import _ log = pykolab.getLogger('pykolab.cli') conf = pykolab.getConf() def __init__(): commands.register('user_info', execute, description="Display user information.") def execute(*args, **kw): from pykolab import wap_client try: user = conf.cli_args.pop(0) except IndexError, errmsg: user = utils.ask_question(_("User")) # Create the authentication object. # TODO: Binds with superuser credentials! wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw")) user = wap_client.user_info(user) print user