3 commits - kolabd/process.py pykolab/auth tests/functional
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed Dec 26 16:29:38 CET 2012
kolabd/process.py | 3 +
pykolab/auth/ldap/__init__.py | 30 +++++++++++++++++--
tests/functional/purge_imap.py | 5 +++
tests/functional/test_kolabd/test_002_user_rename.py | 26 +++++++++++++---
4 files changed, 57 insertions(+), 7 deletions(-)
New commits:
commit 5fe27b7621d7603cbe95baa452514da88f926d98
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 16:28:42 2012 +0100
Sleep for a second or so, otherwise we loop very quickly - also accept a KeyboardInterrupt exception to bail out
diff --git a/kolabd/process.py b/kolabd/process.py
index f5f5352..70b535a 100644
--- a/kolabd/process.py
+++ b/kolabd/process.py
@@ -43,7 +43,10 @@ class KolabdProcess(multiprocessing.Process):
auth = Auth(domain)
auth.connect(domain)
auth.synchronize()
+ except KeyboardInterrupt:
+ break
except Exception, errmsg:
log.error(_("Error in process %r, terminating:\n\t%r") % (self.name, errmsg))
import traceback
traceback.print_exc()
+ time.sleep(1)
commit 5450ee2039d3af5bfaa2d3734dfe7800e5b1aa24
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 16:26:13 2012 +0100
Update test to run with and without a Kolab daemon running (or picking things up in the expected timeframe)
diff --git a/tests/functional/purge_imap.py b/tests/functional/purge_imap.py
index d3827a4..67d4aec 100644
--- a/tests/functional/purge_imap.py
+++ b/tests/functional/purge_imap.py
@@ -1,3 +1,5 @@
+import time
+
import pykolab
from pykolab import wap_client
@@ -6,8 +8,11 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
def purge_imap():
+ time.sleep(2)
+
imap = IMAP()
imap.connect()
+
for folder in imap.lm():
try:
imap.dm(folder)
diff --git a/tests/functional/test_kolabd/test_002_user_rename.py b/tests/functional/test_kolabd/test_002_user_rename.py
index dff9256..f526ade 100644
--- a/tests/functional/test_kolabd/test_002_user_rename.py
+++ b/tests/functional/test_kolabd/test_002_user_rename.py
@@ -21,7 +21,7 @@ class TestKolabDaemon(unittest.TestCase):
from tests.functional.user_add import user_add
user_add("John", "Doe")
- time.sleep(5)
+ time.sleep(2)
@classmethod
def teardown_class(self, *args, **kw):
@@ -34,6 +34,15 @@ class TestKolabDaemon(unittest.TestCase):
policy is applied, and the IMAP INBOX folder for the user is
renamed.
"""
+ auth = Auth()
+ auth.connect()
+ recipient = auth.find_recipient('john.doe at example.org')
+ 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/john.doe at example.org')
@@ -49,14 +58,23 @@ class TestKolabDaemon(unittest.TestCase):
user_info['uid'] = 'sixpack'
user_edit = wap_client.user_edit(recipient, user_info)
- time.sleep(5)
+ 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'] == 'joe.sixpack at example.org':
+ 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'], 'joe.sixpack at example.org')
+ print imap.lm()
+
folders = imap.lm('user/john.doe at example.org')
- self.assertEqual(len(folders), 0)
+ self.assertEqual(len(folders), 0, "INBOX for john.doe still exists")
folders = imap.lm('user/joe.sixpack at example.org')
- self.assertEqual(len(folders), 1)
+ self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
commit b11ef43b54a16e731d5e4ea7e546e1a17cac5665
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 16:24:46 2012 +0100
Take in to account a _change_none_user can still require a mailbox rename
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index c538083..9198219 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1453,10 +1453,34 @@ class LDAP(pykolab.base.Base):
"""
result_attribute = conf.get('cyrus-sasl', 'result_attribute')
- rcpt_addrs = self.recipient_policy(entry)
+ old_canon_attr = None
- for key in rcpt_addrs.keys():
- entry[key] = rcpt_addrs[key]
+ _entry = cache.get_entry(self.domain, entry, update=False)
+
+ if not _entry == None and _entry.__dict__.has_key('result_attribute') and not _entry.result_attribute == '':
+ old_canon_attr = _entry.result_attribute
+
+ entry_changes = self.recipient_policy(entry)
+
+ if entry.has_key(result_attribute) and entry_changes.has_key(result_attribute):
+ if not entry[result_attribute] == entry_changes[result_attribute]:
+ old_canon_attr = entry[result_attribute]
+
+ log.debug(
+ _("Result from recipient policy: %r") % (entry_changes),
+ level=8
+ )
+
+ if entry_changes.has_key(result_attribute) and not old_canon_attr == None:
+ if not entry_changes[result_attribute] == old_canon_attr:
+ self.imap.user_mailbox_rename(
+ old_canon_attr,
+ entry_changes[result_attribute]
+ )
+
+ for key in entry_changes.keys():
+ entry[key] = entry_changes[key]
+ self.set_entry_attribute(entry, key, entry[key])
cache.get_entry(self.domain, entry)
More information about the commits
mailing list