mail_relay_test.sh
1.46 KB
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
. $(dirname $0)/test_helper.sh
test_inbound_list_mail() {
run_on integration create-list mylist foo@example.com
# sending FROM EMAIL RELAY HOST
run_on email send-email foo@example.com mylist@listas.softwarepublico.dev
messages=$(run_on integration wait-for-messages mylist)
run_on integration remove-list mylist
assertEquals 'Message did not arrive at the mailing list' '1' "$messages"
}
test_inbound_regular_mail() {
messages_before=$(run_on integration sudo grep -c '^From.*foo@example.com' /var/mail/root)
run_on email send-email foo@example.com root@softwarepublico.dev
n=0
while [ $n -lt 10 ]; do
sleep 1
messages=$(run_on integration sudo grep -c '^From.*foo@example.com' /var/mail/root)
if [ "$messages" -gt "$messages_before" ]; then
return
else
n=$(($n + 1))
fi
done
fail "didn't receive incoming email"
}
_test_outbound_email() {
machine="$1"
run_on email clear-email-queue
run_on $machine send-email sender@example.com receiver@example.com
messages=$(run_on email wait-for-email-to receiver@example.com)
run_on email clear-email-queue
assertEquals 'Message was not delivered through relay' 1 "$messages"
}
test_outbound_email_integration() {
_test_outbound_email integration
}
test_outbound_email_database() {
_test_outbound_email database
}
test_outbound_email_social() {
_test_outbound_email social
}
test_outbound_email_reverseproxy() {
_test_outbound_email reverseproxy
}
load_shunit2