Add Test and small Fixes.
postfix restart via supervisorctl is buggy. see.: https://github.com/tomav/docker-mailserver/issues/552#issuecomment-335035758
This commit is contained in:
parent
190cd4ecb8
commit
6e39d63697
|
@ -8,7 +8,7 @@ services:
|
|||
install:
|
||||
- travis_retry travis_wait make build-no-cache
|
||||
script:
|
||||
- make generate-accounts run fixtures tests
|
||||
- make generate-accounts run generate-accounts-after-run fixtures tests
|
||||
after_script:
|
||||
- make clean
|
||||
notifications:
|
||||
|
|
8
Makefile
8
Makefile
|
@ -160,7 +160,10 @@ run:
|
|||
-h mail.my-domain.com -t $(NAME)
|
||||
sleep 20
|
||||
|
||||
|
||||
generate-accounts-after-run:
|
||||
docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
||||
sleep 10
|
||||
|
||||
fixtures:
|
||||
cp config/postfix-accounts.cf config/postfix-accounts.cf.bak
|
||||
# Setup sieve & create filtering folder (INBOX/spam)
|
||||
|
@ -175,6 +178,7 @@ fixtures:
|
|||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-recipient-delimiter.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user2.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-added.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user-and-cc-local-alias.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-external.txt"
|
||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-local.txt"
|
||||
|
@ -188,7 +192,7 @@ fixtures:
|
|||
|
||||
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||
# Wait for mails to be analyzed
|
||||
sleep 60
|
||||
sleep 75
|
||||
|
||||
tests:
|
||||
# Start tests
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
#! /bin/bash
|
||||
while true; do
|
||||
|
||||
# Prevent a start too early
|
||||
sleep 5
|
||||
|
||||
# change directory
|
||||
cd /tmp/docker-mailserver
|
||||
|
||||
# Update / generate after start
|
||||
echo 'Makeing new chksum'
|
||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||
|
||||
# Run forever
|
||||
while true; do
|
||||
|
||||
# Check postfix-virtual.cf exist else break
|
||||
if [ ! -f postfix-virtual.cf ]; then
|
||||
echo 'postfix-virtual.cf is missing! exit!'
|
||||
|
@ -15,10 +25,6 @@ if [ ! -f postfix-accounts.cf ]; then
|
|||
break;
|
||||
fi
|
||||
|
||||
# Check chksum exist else create
|
||||
if [ ! -f chksum ]; then
|
||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||
fi
|
||||
|
||||
# Get chksum and check it.
|
||||
chksum=$(sha512sum -c chksum)
|
||||
|
@ -100,10 +106,18 @@ if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
|
|||
if [ `find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c .` != 0 ]; then
|
||||
chown -R 5000:5000 /var/mail
|
||||
fi
|
||||
|
||||
|
||||
#supervisorctl restart postfix # Buggy causes error while testing.
|
||||
postfix reload
|
||||
|
||||
# Prevent restart of dovecot when smtp_only=1
|
||||
if [ ! -f $SMTP_ONLY = 1 ]; then
|
||||
supervisorctl restart dovecot
|
||||
fi
|
||||
|
||||
supervisorctl restart postfix
|
||||
supervisorctl restart dovecot
|
||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||
echo 'Update chksum'
|
||||
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
a1 LOGIN added@localhost.localdomain mypassword
|
||||
a3 EXAMINE INBOX
|
||||
a4 FETCH 1 BODY[]
|
||||
a5 LOGOUT
|
|
@ -0,0 +1,4 @@
|
|||
USER added@localhost.localdomain
|
||||
PASS mypassword
|
||||
LIST
|
||||
quit
|
|
@ -0,0 +1,4 @@
|
|||
EHLO mail
|
||||
AUTH LOGIN YWRkZWRAbG9jYWxob3N0LmxvY2FsZG9tYWlu
|
||||
Bn3JKisq4HQ2RO==
|
||||
QUIT
|
|
@ -0,0 +1,4 @@
|
|||
EHLO mail
|
||||
AUTH LOGIN YWRkZWRAbG9jYWxob3N0LmxvY2FsZG9tYWlu
|
||||
bXlwYXNzd29yZA==
|
||||
QUIT
|
|
@ -0,0 +1,3 @@
|
|||
EHLO mail
|
||||
AUTH PLAIN YWRkZWRAbG9jYWxob3N0LmxvY2FsZG9tYWluAGFkZGVkQGxvY2FsaG9zdC5sb2NhbGRvbWFpbgBCQURQQVNTV09SRA==
|
||||
QUIT
|
|
@ -0,0 +1,3 @@
|
|||
EHLO mail
|
||||
AUTH PLAIN YWRkZWRAbG9jYWxob3N0LmxvY2FsZG9tYWluAGFkZGVkQGxvY2FsaG9zdC5sb2NhbGRvbWFpbgBteXBhc3N3b3Jk
|
||||
QUIT
|
|
@ -0,0 +1,12 @@
|
|||
HELO mail.external.tld
|
||||
MAIL FROM: user@external.tld
|
||||
RCPT TO: added@localhost.localdomain
|
||||
DATA
|
||||
From: Docker Mail Server <dockermailserver@external.tld>
|
||||
To: Existing Local User <added@localhost.localdomain>
|
||||
Date: Sat, 22 May 2010 07:43:25 -0400
|
||||
Subject: Test Message
|
||||
This is a test mail.
|
||||
|
||||
.
|
||||
QUIT
|
|
@ -197,6 +197,11 @@ load 'test_helper/bats-assert/load'
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking imap: added user authentication works" {
|
||||
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/added-imap-auth.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# pop
|
||||
#
|
||||
|
@ -211,6 +216,11 @@ load 'test_helper/bats-assert/load'
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking pop: added user authentication works" {
|
||||
run docker exec mail_pop3 /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/added-pop3-auth.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# sasl
|
||||
#
|
||||
|
@ -264,10 +274,30 @@ load 'test_helper/bats-assert/load'
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking smtp: added user authentication works with good password (plain)" {
|
||||
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/added-smtp-auth-plain.txt | grep 'Authentication successful'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking smtp: added user authentication fails with wrong password (plain)" {
|
||||
run docker exec mail /bin/sh -c "nc -w 20 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/added-smtp-auth-plain-wrong.txt | grep 'authentication failed'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking smtp: added user authentication works with good password (login)" {
|
||||
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/added-smtp-auth-login.txt | grep 'Authentication successful'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking smtp: added user authentication fails with wrong password (login)" {
|
||||
run docker exec mail /bin/sh -c "nc -w 20 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/added-smtp-auth-login-wrong.txt | grep 'authentication failed'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking smtp: delivers mail to existing account" {
|
||||
run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | wc -l"
|
||||
assert_success
|
||||
assert_output 9
|
||||
assert_output 10
|
||||
}
|
||||
|
||||
@test "checking smtp: delivers mail to existing alias" {
|
||||
|
@ -349,6 +379,7 @@ load 'test_helper/bats-assert/load'
|
|||
assert_success
|
||||
[ "${lines[0]}" = "user1@localhost.localdomain" ]
|
||||
[ "${lines[1]}" = "user2@otherdomain.tld" ]
|
||||
[ "${lines[2]}" = "added@localhost.localdomain" ]
|
||||
}
|
||||
|
||||
@test "checking accounts: user mail folders for user1" {
|
||||
|
@ -363,6 +394,12 @@ load 'test_helper/bats-assert/load'
|
|||
assert_output 7
|
||||
}
|
||||
|
||||
@test "checking accounts: user mail folders for added user" {
|
||||
run docker exec mail /bin/bash -c "ls -A /var/mail/localhost.localdomain/added | grep -E '.Drafts|.Sent|.Trash|cur|new|subscriptions|tmp' | wc -l"
|
||||
assert_success
|
||||
assert_output 7
|
||||
}
|
||||
|
||||
@test "checking accounts: comments are not parsed" {
|
||||
run docker exec mail /bin/bash -c "ls /var/mail | grep 'comment'"
|
||||
assert_failure
|
||||
|
@ -1315,7 +1352,7 @@ load 'test_helper/bats-assert/load'
|
|||
}
|
||||
|
||||
@test "checking restart of process: amavisd-new" {
|
||||
run docker exec mail /bin/bash -c "pkill amavi && sleep 10 && ps aux --forest | grep -v grep | grep '/usr/sbin/amavisd-new (master)'"
|
||||
run docker exec mail /bin/bash -c "pkill amavi && sleep 12 && ps aux --forest | grep -v grep | grep '/usr/sbin/amavisd-new (master)'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue