summaryrefslogtreecommitdiffstats
path: root/tests/functional/purge_users.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/purge_users.py')
-rw-r--r--tests/functional/purge_users.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/functional/purge_users.py b/tests/functional/purge_users.py
new file mode 100644
index 0000000..1b18cb0
--- /dev/null
+++ b/tests/functional/purge_users.py
@@ -0,0 +1,37 @@
+import pykolab
+
+from pykolab import wap_client
+from pykolab.auth import Auth
+from pykolab.imap import IMAP
+
+conf = pykolab.getConf()
+
+def purge_users():
+ wap_client.authenticate(conf.get("ldap", "bind_dn"), conf.get("ldap", "bind_pw"))
+
+ users = wap_client.users_list()
+ for user in users['list']:
+ wap_client.user_delete({'user': user})
+
+ auth = Auth()
+ domains = auth.list_domains()
+
+ imap = IMAP()
+ imap.connect()
+
+ folders = []
+
+ for domain,aliases in domains:
+ folders.extend(imap.lm("user/%%@%s" % (domain)))
+
+ for folder in folders:
+ user = folder.replace('user/','')
+
+ recipient = auth.find_recipient(user)
+
+ if len(recipient) == 0 or recipient == []:
+ try:
+ imap.dm(folder)
+ except:
+ pass
+