summaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-11 13:04:38 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-11 13:04:38 +0200
commit4f566bcd9cecfb26363cbd0f047b5c6e9a513c6f (patch)
treecc0b646e6c6dcff322fcc4bd2aca31ca8c8ccc2f /tests/functional
parentb748e6930703fcaf8910248d0b8af0acb4d00f82 (diff)
downloadpykolab-4f566bcd9cecfb26363cbd0f047b5c6e9a513c6f.tar.gz
New functional tests for policy_uid setting
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/test_wap_client/test_007_policy_uid.py176
1 files changed, 176 insertions, 0 deletions
diff --git a/tests/functional/test_wap_client/test_007_policy_uid.py b/tests/functional/test_wap_client/test_007_policy_uid.py
new file mode 100644
index 0000000..534ebda
--- /dev/null
+++ b/tests/functional/test_wap_client/test_007_policy_uid.py
@@ -0,0 +1,176 @@
+from ConfigParser import RawConfigParser
+import time
+import unittest
+
+import pykolab
+from pykolab import wap_client
+from pykolab.auth import Auth
+from pykolab.imap import IMAP
+
+conf = pykolab.getConf()
+
+class TestPolicyUid(unittest.TestCase):
+
+ def remove_option(self, section, option):
+ self.config.remove_option(section, option)
+
+ fp = open(conf.config_file, "w")
+ self.config.write(fp)
+ fp.close()
+
+ def set(self, section, option, value):
+ self.config.set(section, option, value)
+
+ fp = open(conf.config_file, "w")
+ self.config.write(fp)
+ fp.close()
+
+ @classmethod
+ def setup_class(self, *args, **kw):
+ self.config = RawConfigParser()
+ self.config.read(conf.config_file)
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+ self.user = {
+ 'local': 'john.doe',
+ 'domain': 'example.org'
+ }
+
+ self.login = conf.get('ldap', 'bind_dn')
+ self.password = conf.get('ldap', 'bind_pw')
+ self.domain = conf.get('kolab', 'primary_domain')
+
+ result = wap_client.authenticate(self.login, self.password, self.domain)
+
+ @classmethod
+ def teardown_class(self, *args, **kw):
+ self.config.remove_option('example.org', 'policy_uid')
+
+ fp = open(conf.config_file, "w")
+ self.config.write(fp)
+ fp.close()
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+ 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('john.doe@example.org')
+
+ 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_002_givenname_dot_surname(self):
+ self.set('example.org', 'policy_uid', '%(givenname)s.%(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('john.doe@example.org')
+
+ user_info = wap_client.user_info(user)
+
+ self.assertEqual(user_info['uid'], "John.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('john.doe@example.org')
+
+ user_info = wap_client.user_info(user)
+
+ self.assertEqual(user_info['uid'], "J.Doe")
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+ def test_004_givenname(self):
+ self.set('example.org', 'policy_uid', '%(givenname)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('john.doe@example.org')
+
+ user_info = wap_client.user_info(user)
+
+ self.assertEqual(user_info['uid'], "John")
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+ def test_005_lowercase_givenname(self):
+ self.set('example.org', 'policy_uid', '%(givenname)s.lower()')
+
+ 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('john.doe@example.org')
+
+ user_info = wap_client.user_info(user)
+
+ self.assertEqual(user_info['uid'], "john")
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+ def test_006_lowercase_givenname_surname(self):
+ self.set('example.org', 'policy_uid', "%(givenname)s.lower().%(surname)s.lower()")
+
+ 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('john.doe@example.org')
+
+ user_info = wap_client.user_info(user)
+
+ self.assertEqual(user_info['uid'], "john.doe")
+
+ from tests.functional.purge_users import purge_users
+ purge_users()
+
+