forked from hardware/mailserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (118 loc) · 5.04 KB
/
Makefile
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
NAME = hardware/mailserver:testing
all: build-no-cache init fixtures run clean
all-fast: build init fixtures run clean
no-build: init fixtures run clean
build-no-cache:
docker build --no-cache -t $(NAME) .
build:
docker build -t $(NAME) .
init:
-docker rm -f mariadb redis mailserver_default mailserver_reverse mailserver_ecdsa
sleep 2
docker run \
-d \
--name mariadb \
-e MYSQL_ROOT_PASSWORD=testpasswd \
-e MYSQL_DATABASE=postfix \
-e MYSQL_USER=postfix \
-e MYSQL_PASSWORD=testpasswd \
-v "`pwd`/test/config/mariadb":/docker-entrypoint-initdb.d \
-t mariadb:10.2
docker run \
-d \
--name redis \
-t redis:4.0-alpine
sleep 10
docker run \
-d \
--name mailserver_default \
--link mariadb:mariadb \
--link redis:redis \
-e DBPASS=testpasswd \
-e RSPAMD_PASSWORD=testpasswd \
-e VMAILUID=`id -u` \
-e VMAILGID=`id -g` \
-e ADD_DOMAINS=domain2.tld,domain3.tld \
-e RECIPIENT_DELIMITER=: \
-e TESTING=true \
-v "`pwd`/test/share/tests":/tmp/tests \
-v "`pwd`/test/share/ssl/rsa":/var/mail/ssl \
-v "`pwd`/test/share/postfix/custom.conf":/var/mail/postfix/custom.conf \
-h mail.domain.tld \
-t $(NAME)
docker run \
-d \
--name mailserver_reverse \
--link mariadb:mariadb \
--link redis:redis \
-e FQDN=mail.domain.tld \
-e DOMAIN=domain.tld \
-e DBPASS=/tmp/passwd/mariadb \
-e REDIS_HOST=redis \
-e REDIS_PORT=6379 \
-e REDIS_PASS=/tmp/passwd/redis \
-e RSPAMD_PASSWORD=/tmp/passwd/rspamd \
-e VMAILUID=`id -u` \
-e VMAILGID=`id -g` \
-e VMAIL_SUBDIR=subdir \
-e RELAY_NETWORKS="192.168.0.0/16 172.16.0.0/12 10.0.0.0/8" \
-e DISABLE_CLAMAV=true \
-e DISABLE_SIEVE=true \
-e DISABLE_SIGNING=true \
-e DISABLE_GREYLISTING=true \
-e DISABLE_RATELIMITING=true \
-e DISABLE_DNS_RESOLVER=true \
-e ENABLE_POP3=true \
-e ENABLE_ENCRYPTION=true \
-e OPENDKIM_KEY_LENGTH=4096 \
-e TESTING=true \
-v "`pwd`/test/share/tests":/tmp/tests \
-v "`pwd`/test/share/passwd":/tmp/passwd \
-v "`pwd`/test/share/ssl/rsa":/var/mail/ssl \
-v "`pwd`/test/share/sieve/custom.sieve":/var/mail/sieve/custom.sieve \
-v "`pwd`/test/share/letsencrypt":/etc/letsencrypt \
-t $(NAME)
docker run \
-d \
--name mailserver_ecdsa \
--link mariadb:mariadb \
--link redis:redis \
-e DBPASS=testpasswd \
-e RSPAMD_PASSWORD=testpasswd \
-e VMAILUID=`id -u` \
-e VMAILGID=`id -g` \
-e DISABLE_CLAMAV=true \
-e DISABLE_RSPAMD_MODULE=rbl,mx_check,url_redirector \
-e TESTING=true \
-v "`pwd`/test/share/ssl/ecdsa":/var/mail/ssl \
-v "`pwd`/test/share/postfix/custom.ecdsa.conf":/var/mail/postfix/custom.conf \
-h mail.domain.tld \
-t $(NAME)
docker exec mailserver_default /bin/sh -c "apt-get update && apt-get install -y -q netcat"
docker exec mailserver_reverse /bin/sh -c "apt-get update && apt-get install -y -q netcat"
fixtures:
# Wait for clamav virus database update
sleep 120
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-existing-user.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-existing-user-spam-learning.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-valid-user-subaddress.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-non-existing-user.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-existing-alias.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-spam-to-existing-user.txt"
docker exec mailserver_default /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-virus-to-existing-user.txt"
docker exec mailserver_default /bin/sh -c "openssl s_client -ign_eof -connect 0.0.0.0:587 -starttls smtp < /tmp/tests/email-templates/internal-user-to-existing-user.txt"
sleep 2
docker exec mailserver_default /bin/sh -c "openssl s_client -ign_eof -connect 0.0.0.0:993 < /tmp/tests/sieve/trigger-spam-ham-learning.txt"
docker exec mailserver_reverse /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-existing-user.txt"
docker exec mailserver_reverse /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-valid-user-subaddress-with-default-separator.txt"
docker exec mailserver_reverse /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-non-existing-user.txt"
docker exec mailserver_reverse /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-to-existing-alias.txt"
docker exec mailserver_reverse /bin/sh -c "nc 0.0.0.0 25 < /tmp/tests/email-templates/external-spam-to-existing-user.txt"
docker exec mailserver_reverse /bin/sh -c "openssl s_client -ign_eof -connect 0.0.0.0:587 -starttls smtp < /tmp/tests/email-templates/internal-user-to-existing-user.txt"
# Wait until all mails have been processed
sleep 10
run:
./test/bats/bin/bats test/tests.bats
clean:
docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi
docker volume ls -qf dangling=true | xargs -r docker volume rm