You've already forked docker-mailserver
mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-09 23:07:35 +02:00
Merge pull request #29 from tomav/add-unit-tests
Add unit / integration tests
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.DS_Store
|
||||
docker-compose.yml
|
||||
postfix/ssl/*
|
||||
postfix/ssl/*
|
||||
assert.sh*
|
||||
|
6
.travis.yml
Normal file
6
.travis.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
language: bash
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- make all
|
@@ -4,7 +4,7 @@ MAINTAINER Thomas VIAL
|
||||
# Packages
|
||||
RUN apt-get update -q --fix-missing
|
||||
RUN apt-get -y upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install vim postfix sasl2-bin courier-imap courier-imap-ssl courier-authdaemon supervisor gamin amavisd-new spamassassin clamav clamav-daemon libnet-dns-perl libmail-spf-perl pyzor razor arj bzip2 cabextract cpio file gzip nomarch p7zip pax unzip zip zoo rsyslog
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install vim postfix sasl2-bin courier-imap courier-imap-ssl courier-authdaemon supervisor gamin amavisd-new spamassassin clamav clamav-daemon libnet-dns-perl libmail-spf-perl pyzor razor arj bzip2 cabextract cpio file gzip nomarch p7zip pax unzip zip zoo rsyslog mailutils
|
||||
RUN apt-get autoclean
|
||||
|
||||
# Configures Saslauthd
|
||||
|
30
Makefile
Normal file
30
Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
NAME = tvial/docker-mailserver
|
||||
VERSION = $(TRAVIS_BUILD_ID)
|
||||
|
||||
all: build run prepare fixtures tests
|
||||
|
||||
build:
|
||||
docker build --no-cache -t $(NAME):$(VERSION) .
|
||||
|
||||
run:
|
||||
# Copy test files
|
||||
cp test/accounts.cf postfix/
|
||||
cp test/virtual postfix/
|
||||
# Run container
|
||||
docker run -d --name mail -v "`pwd`/postfix":/tmp/postfix -v "`pwd`/spamassassin":/tmp/spamassassin -h mail.my-domain.com -t $(NAME):$(VERSION)
|
||||
sleep 15
|
||||
|
||||
prepare:
|
||||
# Reinitialize logs
|
||||
docker exec mail /bin/sh -c 'echo "" > /var/log/mail.log'
|
||||
|
||||
fixtures:
|
||||
# Sending test mails
|
||||
docker exec mail /bin/sh -c 'echo "This is a test mail" | mail -s "TEST-001" user@localhost.localdomain'
|
||||
docker exec mail /bin/sh -c 'echo "This is a test mail" | mail -s "TEST-002" nouser@localhost.localdomain'
|
||||
docker exec mail /bin/sh -c 'echo "This is a test mail" | mail -s "TEST-003" alias1@localhost.localdomain'
|
||||
docker exec mail /bin/sh -c 'echo "This is a test mail" | mail -s "TEST-004" alias2@localhost.localdomain'
|
||||
|
||||
tests:
|
||||
# Start tests
|
||||
./test/test.sh
|
@@ -1,5 +1,7 @@
|
||||
# docker-mailserver
|
||||
|
||||
[](https://travis-ci.org/tomav/docker-mailserver)
|
||||
|
||||
A fullstack but simple mail server (smtp, imap, antispam, antivirus...).
|
||||
Only configuration files, no SQL database. Keep it simple and versioned.
|
||||
Easy to deploy and upgrade.
|
||||
|
@@ -9,7 +9,7 @@ readme_directory = no
|
||||
# myhostname =
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
mydestination = localhost.localdomain, localhost
|
||||
mydestination =
|
||||
relayhost =
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.17.0.0/16
|
||||
mailbox_size_limit = 0
|
||||
|
2
test/accounts.cf
Normal file
2
test/accounts.cf
Normal file
@@ -0,0 +1,2 @@
|
||||
user1@localhost.localdomain|mypassword
|
||||
user2@otherdomain.tld|mypassword
|
25
test/test.sh
Executable file
25
test/test.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set up test framework
|
||||
wget -q https://raw.github.com/lehmannro/assert.sh/master/assert.sh
|
||||
source assert.sh
|
||||
|
||||
# Testing that services are running
|
||||
assert_raises "docker exec mail ps aux --forest | grep '/usr/lib/postfix/master'" "true"
|
||||
assert_raises "docker exec mail ps aux --forest | grep '/usr/sbin/saslauthd'" "true"
|
||||
assert_raises "docker exec mail ps aux --forest | grep '/usr/sbin/clamd'" "true"
|
||||
assert_raises "docker exec mail ps aux --forest | grep '/usr/sbin/amavisd-new'" "true"
|
||||
|
||||
# Testing user creation
|
||||
assert "docker exec mail ls -A /var/mail/localhost.localdomain/user1" "cur\nnew\ntmp"
|
||||
assert "docker exec mail ls /var/mail/otherdomain.tld/user2" "cur\nnew\ntmp"
|
||||
|
||||
# Testing that mail is received for existing user
|
||||
assert_raises "docker exec mail grep 'status=sent (delivered to maildir)' /var/log/mail.log" "false"
|
||||
assert "docker exec mail ls -A /var/mail/localhost.localdomain/user1/new | wc -l" "1"
|
||||
|
||||
# Testing presence of freshclam CRON
|
||||
assert "docker exec mail crontab -l" "0 1 * * * /usr/bin/freshclam --quiet"
|
||||
|
||||
# Ending tests
|
||||
assert_end
|
2
test/virtual
Normal file
2
test/virtual
Normal file
@@ -0,0 +1,2 @@
|
||||
alias1@localhost.localdomain user1@localhost.localdomain
|
||||
alias2@localhost.localdomain external1@otherdomain.tld
|
Reference in New Issue
Block a user