1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
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 TestKolabDaemon(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
from tests.functional.purge_users import purge_users
purge_users()
self.user = {
'local': 'john.doe',
'domain': 'example.org'
}
from tests.functional.user_add import user_add
user_add("John", "Doe")
time.sleep(2)
@classmethod
def teardown_class(self, *args, **kw):
from tests.functional.purge_users import purge_users
purge_users()
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('john.doe@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@example.org')
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'] == 'joe.sixpack@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@example.org')
print imap.lm()
folders = imap.lm('user/john.doe@example.org')
self.assertEqual(len(folders), 0, "INBOX for john.doe still exists")
folders = imap.lm('user/joe.sixpack@example.org')
self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
|