This repository has been archived by the owner on Jan 3, 2018. It is now read-only.
/
testEmailForwarding.py
executable file
·88 lines (65 loc) · 3.3 KB
/
testEmailForwarding.py
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
81
82
83
84
85
86
#!/usr/bin/env python
import unittest
import time
import datetime
import string
import subprocess
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from helperKolabWAP import KolabWAPTestHelpers
# assumes password for cn=Directory Manager is test
# will create a new user
# will create a new mail forwarding account, to the email of the created user
# will send email from command line
# will login to roundcube and check for the new email
class KolabEmailMailForwarding(unittest.TestCase):
def setUp(self):
self.kolabWAPhelper = KolabWAPTestHelpers()
self.driver = self.kolabWAPhelper.init_driver()
def test_mail_forwarding(self):
kolabWAPhelper = self.kolabWAPhelper
kolabWAPhelper.log("Running test: test_mail_forwarding")
# login Directory Manager, create a user
kolabWAPhelper.login_kolab_wap("/kolab-webadmin", "cn=Directory Manager", "test")
# add the user
username, emailLogin, password = kolabWAPhelper.create_user()
# create a forward address
username2, emailForwardAddress, password2 = kolabWAPhelper.create_user(forward_to=emailLogin)
kolabWAPhelper.logout_kolab_wap()
# send email to the forward address from command line
print "sending email to " + emailForwardAddress
subject = 'for ' + username
subprocess.call(['/bin/bash', '-c', 'echo "test" | mail -s "' + subject + '" ' + emailForwardAddress])
kolabWAPhelper.wait_loading(2.0)
# login user to roundcube and check for email
kolabWAPhelper.login_roundcube("/roundcubemail", emailLogin, password)
kolabWAPhelper.check_email_received(subject)
kolabWAPhelper.logout_roundcube()
def test_mail_forwarding_external(self):
kolabWAPhelper = self.kolabWAPhelper
kolabWAPhelper.log("Running test: test_mail_forwarding_external")
# login Directory Manager, create a user
kolabWAPhelper.login_kolab_wap("/kolab-webadmin", "cn=Directory Manager", "test")
# please modify following line to add a domain that actually can receive emails, ie. has a valid MX record
enabled_maildomain="soliderp.net"
# quit the test if that domain does not exist in the current setup
kolabWAPhelper.select_domain(enabled_maildomain);
# add the user
username, emailLogin, password = kolabWAPhelper.create_user()
# create a forward address
# using an external echo address (see https://de.wikipedia.org/wiki/Echo-Mailer)
username2, emailForwardAddress, password2 = kolabWAPhelper.create_user(forward_to="echo@tu-berlin.de")
kolabWAPhelper.logout_kolab_wap()
# login user to roundcube and check for email
kolabWAPhelper.login_roundcube("/roundcubemail", emailLogin, password)
print "sending email to " + emailForwardAddress
emailSubjectLine = kolabWAPhelper.send_email(emailForwardAddress)
kolabWAPhelper.wait_loading(5.0)
kolabWAPhelper.check_email_received("Re: " + emailSubjectLine)
kolabWAPhelper.logout_roundcube()
def tearDown(self):
# write current page for debugging purposes
self.kolabWAPhelper.log_current_page()
self.driver.close()
if __name__ == "__main__":
unittest.main()