diff options
-rw-r--r-- | pykolab/auth/__init__.py | 3 | ||||
-rw-r--r-- | pykolab/auth/ldap/__init__.py | 19 | ||||
-rw-r--r-- | tests/functional/test_wallace/test_007_invitationpolicy.py | 23 | ||||
-rw-r--r-- | wallace/module_invitationpolicy.py | 12 |
4 files changed, 54 insertions, 3 deletions
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py index cba3b62..88b46bc 100644 --- a/pykolab/auth/__init__.py +++ b/pykolab/auth/__init__.py @@ -222,6 +222,9 @@ class Auth(pykolab.base.Base): def extract_recipient_addresses(self, entry): return self._auth.extract_recipient_addresses(entry) + def list_delegators(self, user): + return self._auth.list_delegators(user) + def list_domains(self, domain=None): """ List the domains using the auth_mechanism setting in the kolab diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py index 615a3b4..dd477ef 100644 --- a/pykolab/auth/ldap/__init__.py +++ b/pykolab/auth/ldap/__init__.py @@ -429,6 +429,25 @@ class LDAP(pykolab.base.Base): return recipient_addresses + def list_delegators(self, entry_id): + """ + Get a list of user records the given user is set to be a delegatee + """ + delegators = [] + + mailbox_attribute = conf.get('cyrus-sasl', 'result_attribute') + if mailbox_attribute == None: + mailbox_attribute = 'mail' + + for __delegator in self.search_entry_by_attribute('kolabDelegate', entry_id): + (_dn, _delegator) = __delegator + _delegator['dn'] = _dn; + _delegator['_mailbox_basename'] = _delegator[mailbox_attribute] if _delegator.has_key(mailbox_attribute) else None + if isinstance(_delegator['_mailbox_basename'], list): + _delegator['_mailbox_basename'] = _delegator['_mailbox_basename'][0] + delegators.append(_delegator) + + return delegators def find_recipient(self, address="*", exclude_entry_id=None): """ diff --git a/tests/functional/test_wallace/test_007_invitationpolicy.py b/tests/functional/test_wallace/test_007_invitationpolicy.py index dee15bf..090dcf3 100644 --- a/tests/functional/test_wallace/test_007_invitationpolicy.py +++ b/tests/functional/test_wallace/test_007_invitationpolicy.py @@ -306,7 +306,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase): from tests.functional.user_add import user_add user_add("John", "Doe", kolabinvitationpolicy=self.john['kolabinvitationpolicy'], preferredlanguage=self.john['preferredlanguage']) - user_add("Jane", "Manager", kolabinvitationpolicy=self.jane['kolabinvitationpolicy'], preferredlanguage=self.jane['preferredlanguage']) + user_add("Jane", "Manager", kolabinvitationpolicy=self.jane['kolabinvitationpolicy'], preferredlanguage=self.jane['preferredlanguage'], kolabdelegate=[self.mark['dn']]) user_add("Jack", "Tentative", kolabinvitationpolicy=self.jack['kolabinvitationpolicy'], preferredlanguage=self.jack['preferredlanguage']) user_add("Mark", "German", kolabinvitationpolicy=self.mark['kolabinvitationpolicy'], preferredlanguage=self.mark['preferredlanguage']) user_add("Lucy", "Meyer", kolabinvitationpolicy=self.lucy['kolabinvitationpolicy'], preferredlanguage=self.lucy['preferredlanguage']) @@ -314,6 +314,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase): time.sleep(1) from tests.functional.synchronize import synchronize_once synchronize_once() + time.sleep(4) # create confidential calendar folder for jane imap = IMAP() @@ -326,6 +327,8 @@ class TestWallaceInvitationpolicy(unittest.TestCase): } } }) + # grant full access for Mark to Jane's calendar + imap.set_acl(imap.folder_quote(self.jane['kolabcalendarfolder']), self.mark['mail'], "lrswipkxtecda") imap.disconnect() @@ -990,6 +993,24 @@ class TestWallaceInvitationpolicy(unittest.TestCase): self.assertEqual(event.get_summary(), "confidential") + def test_013_update_shared_folder(self): + # create an event organized by Mark (a delegate of Jane) into Jane's calendar + start = datetime.datetime(2015,3,10, 9,30,0, tzinfo=pytz.timezone("Europe/Berlin")) + uid = self.create_calendar_event(start, user=self.mark, attendees=[self.jane, self.john], folder=self.jane['kolabcalendarfolder']) + + event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid) + self.assertIsInstance(event, pykolab.xml.Event) + + # send a reply from john to mark + self.send_itip_reply(uid, self.john['mail'], self.mark['mail'], start=start) + + # check for the updated event in jane's calendar + time.sleep(10) + event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid) + self.assertIsInstance(event, pykolab.xml.Event) + self.assertEqual(event.get_attendee(self.john['mail']).get_participant_status(), kolabformat.PartAccepted) + + def test_020_task_assignment_accept(self): start = datetime.datetime(2014,9,10, 19,0,0) uid = self.send_itip_invitation(self.jane['mail'], start, summary='work', template=itip_todo) diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py index 6ffc5e5..1e94f63 100644 --- a/wallace/module_invitationpolicy.py +++ b/wallace/module_invitationpolicy.py @@ -281,6 +281,12 @@ def execute(*args, **kw): receiving_user = auth.get_entry_attributes(None, recipient_user_dn, ['*']) recipient_emails = auth.extract_recipient_addresses(receiving_user) recipient_email = recipient + + # extend with addresses from delegators + receiving_user['_delegated_mailboxes'] = [] + for _delegator in auth.list_delegators(recipient_user_dn): + receiving_user['_delegated_mailboxes'].append(_delegator['_mailbox_basename'].split('@')[0]) + log.debug(_("Recipient emails for %s: %r") % (recipient_user_dn, recipient_emails), level=8) break @@ -729,9 +735,11 @@ def list_user_folders(user_rec, type): for folder in folders: # exclude shared and other user's namespace - # TODO: list shared folders the user has write privileges ? if not ns_other is None and folder.startswith(ns_other): - continue; + # allow shared folders from delegators + if len([_mailbox for _mailbox in user_rec['_delegated_mailboxes'] if folder.startswith(ns_other + _mailbox + '/')]) == 0: + continue; + # TODO: list shared folders the user has write privileges ? if not ns_shared is None and len([_ns for _ns in ns_shared if folder.startswith(_ns)]) > 0: continue; |