MOved bats to dependency and added bats-assert, also updated most test cases to have an ouput of expected/actual values in log (easier to debug)
This commit is contained in:
parent
01e0ed8eca
commit
a0f7f08b94
|
@ -1,6 +1,8 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
.idea
|
.idea
|
||||||
|
test/bats/
|
||||||
|
test/test_helper/
|
||||||
test/config/empty/
|
test/config/empty/
|
||||||
test/config/without-accounts/
|
test/config/without-accounts/
|
||||||
test/config/without-virtual/
|
test/config/without-virtual/
|
||||||
|
|
|
@ -14,7 +14,7 @@ after_script:
|
||||||
env:
|
env:
|
||||||
- SMTP_ONLY=0 ENABLE_LDAP=0 ENABLE_CLAMAV=1 ENABLE_SPAMASSASSIN=1 ENABLE_FAIL2BAN=1 ONE_DIR=1 ENABLE_POP3=1 ENABLE_MANAGESIEVE=1 ENABLE_FETCHMAIL=1 PERMIT_DOCKER=host DMS_DEBUG=0 SA_TAG=1.0 SA_TAG2=2.0 SA_KILL=3.0 VIRUSMAILS_DELETE_DELAY=7 SASL_PASSWD="external domain.com username:password"
|
- SMTP_ONLY=0 ENABLE_LDAP=0 ENABLE_CLAMAV=1 ENABLE_SPAMASSASSIN=1 ENABLE_FAIL2BAN=1 ONE_DIR=1 ENABLE_POP3=1 ENABLE_MANAGESIEVE=1 ENABLE_FETCHMAIL=1 PERMIT_DOCKER=host DMS_DEBUG=0 SA_TAG=1.0 SA_TAG2=2.0 SA_KILL=3.0 VIRUSMAILS_DELETE_DELAY=7 SASL_PASSWD="external domain.com username:password"
|
||||||
- SMTP_ONLY=0 ENABLE_LDAP=0 ENABLE_CLAMAV=0 ENABLE_SPAMASSASSIN=0 ENABLE_FAIL2BAN=0 ONE_DIR=0 ENABLE_POP3=0 ENABLE_MANAGESIEVE=0 ENABLE_FETCHMAIL=0 PERMIT_DOCKER=network DMS_DEBUG=1
|
- SMTP_ONLY=0 ENABLE_LDAP=0 ENABLE_CLAMAV=0 ENABLE_SPAMASSASSIN=0 ENABLE_FAIL2BAN=0 ONE_DIR=0 ENABLE_POP3=0 ENABLE_MANAGESIEVE=0 ENABLE_FETCHMAIL=0 PERMIT_DOCKER=network DMS_DEBUG=1
|
||||||
- SMTP_ONLY=1 ENABLE_LDAP=1 LDAP_SERVER_HOST=ldap LDAP_SEARCH_BASE=ou=people,dc=localhost,dc=localdomain LDAP_BIND_DN=cn=admin,dc=localhost,dc=localdomain ENABLE_SASLAUTHD=1 SASLAUTHD_MECHANISMS=ldap SASLAUTHD_LDAP_SERVER=ldap SASLAUTHD_LDAP_BIND_DN=cn=admin,dc=localhost,dc=localdomain SASLAUTHD_LDAP_PASSWORD=admin SASLAUTHD_LDAP_SEARCH_BASE=ou=people,dc=localhost,dc=localdomain POSTMASTER_ADDRESS=postmaster@localhost.localdomain
|
- SMTP_ONLY=1 ENABLE_LDAP=1 LDAP_SERVER_HOST=ldap LDAP_SEARCH_BASE="ou=people,dc=localhost,dc=localdomain" LDAP_BIND_DN="cn=admin,dc=localhost,dc=localdomain" ENABLE_SASLAUTHD=1 SASLAUTHD_MECHANISMS=ldap SASLAUTHD_LDAP_SERVER=ldap SASLAUTHD_LDAP_BIND_DN="cn=admin,dc=localhost,dc=localdomain" SASLAUTHD_LDAP_PASSWORD=admin SASLAUTHD_LDAP_SEARCH_BASE="ou=people,dc=localhost,dc=localdomain" POSTMASTER_ADDRESS=postmaster@localhost.localdomain
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
slack:
|
slack:
|
||||||
|
|
23
Makefile
23
Makefile
|
@ -2,6 +2,7 @@ NAME = tvial/docker-mailserver:testing
|
||||||
|
|
||||||
all: build-no-cache generate-accounts run fixtures tests clean
|
all: build-no-cache generate-accounts run fixtures tests clean
|
||||||
all-fast: build generate-accounts run fixtures tests clean
|
all-fast: build generate-accounts run fixtures tests clean
|
||||||
|
all-fast-local: build generate-accounts run-local fixtures tests clean
|
||||||
no-build: generate-accounts run fixtures tests clean
|
no-build: generate-accounts run fixtures tests clean
|
||||||
|
|
||||||
build-no-cache:
|
build-no-cache:
|
||||||
|
@ -19,7 +20,7 @@ generate-accounts:
|
||||||
run:
|
run:
|
||||||
ifeq ($(ENABLE_LDAP),1)
|
ifeq ($(ENABLE_LDAP),1)
|
||||||
# Run ldap
|
# Run ldap
|
||||||
docker run -d --name ldap_for_mail \
|
docker run -d --name ldap-for-mail \
|
||||||
-e LDAP_DOMAIN="localhost.localdomain" \
|
-e LDAP_DOMAIN="localhost.localdomain" \
|
||||||
-h mail.my-domain.com -t ldap
|
-h mail.my-domain.com -t ldap
|
||||||
endif
|
endif
|
||||||
|
@ -60,6 +61,18 @@ endif
|
||||||
# Wait for containers to fully start
|
# Wait for containers to fully start
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|
||||||
|
run-local:
|
||||||
|
docker run -d --name mail \
|
||||||
|
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||||
|
-v "`pwd`/test":/tmp/docker-mailserver-test \
|
||||||
|
-v "`pwd`/test/onedir":/var/mail-state \
|
||||||
|
--env-file=.env-testing \
|
||||||
|
--cap-add=NET_ADMIN \
|
||||||
|
--add-host=pop3.example.tld:127.0.0.1 \
|
||||||
|
-h mail.my-domain.com -t $(NAME)
|
||||||
|
# Wait for containers to fully start
|
||||||
|
sleep 15
|
||||||
|
|
||||||
fixtures:
|
fixtures:
|
||||||
cp config/postfix-accounts.cf config/postfix-accounts.cf.bak
|
cp config/postfix-accounts.cf config/postfix-accounts.cf.bak
|
||||||
# Setup sieve & create filtering folder (INBOX/spam)
|
# Setup sieve & create filtering folder (INBOX/spam)
|
||||||
|
@ -83,13 +96,14 @@ fixtures:
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
# Start tests
|
# Start tests
|
||||||
./test/bats/bats test/tests.bats
|
./test/bats/bin/bats test/tests.bats
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
# Remove running test containers
|
# Remove running test containers
|
||||||
-docker rm -f \
|
-docker rm -f \
|
||||||
mail \
|
mail \
|
||||||
ldap_for_mail
|
fail-auth-mailer \
|
||||||
|
ldap-for-mail
|
||||||
|
|
||||||
@if [ -f config/postfix-accounts.cf.bak ]; then\
|
@if [ -f config/postfix-accounts.cf.bak ]; then\
|
||||||
rm -f config/postfix-accounts.cf ;\
|
rm -f config/postfix-accounts.cf ;\
|
||||||
|
@ -98,4 +112,5 @@ clean:
|
||||||
-sudo rm -rf test/onedir \
|
-sudo rm -rf test/onedir \
|
||||||
test/config/empty \
|
test/config/empty \
|
||||||
test/config/without-accounts \
|
test/config/without-accounts \
|
||||||
test/config/without-virtual
|
test/config/without-virtual \
|
||||||
|
test/config/postfix-accounts.cf.bak
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
142
test/bats/bats
142
test/bats/bats
|
@ -1,142 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
version() {
|
|
||||||
echo "Bats 0.4.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
version
|
|
||||||
echo "Usage: bats [-c] [-p | -t] <test> [<test> ...]"
|
|
||||||
}
|
|
||||||
|
|
||||||
help() {
|
|
||||||
usage
|
|
||||||
echo
|
|
||||||
echo " <test> is the path to a Bats test file, or the path to a directory"
|
|
||||||
echo " containing Bats test files."
|
|
||||||
echo
|
|
||||||
echo " -c, --count Count the number of test cases without running any tests"
|
|
||||||
echo " -h, --help Display this help message"
|
|
||||||
echo " -p, --pretty Show results in pretty format (default for terminals)"
|
|
||||||
echo " -t, --tap Show results in TAP format"
|
|
||||||
echo " -v, --version Display the version number"
|
|
||||||
echo
|
|
||||||
echo " For more information, see https://github.com/sstephenson/bats"
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve_link() {
|
|
||||||
$(type -p greadlink readlink | head -1) "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
abs_dirname() {
|
|
||||||
local cwd="$(pwd)"
|
|
||||||
local path="$1"
|
|
||||||
|
|
||||||
while [ -n "$path" ]; do
|
|
||||||
cd "${path%/*}"
|
|
||||||
local name="${path##*/}"
|
|
||||||
path="$(resolve_link "$name" || true)"
|
|
||||||
done
|
|
||||||
|
|
||||||
pwd
|
|
||||||
cd "$cwd"
|
|
||||||
}
|
|
||||||
|
|
||||||
expand_path() {
|
|
||||||
{ cd "$(dirname "$1")" 2>/dev/null
|
|
||||||
local dirname="$PWD"
|
|
||||||
cd "$OLDPWD"
|
|
||||||
echo "$dirname/$(basename "$1")"
|
|
||||||
} || echo "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
BATS_LIBEXEC="$(abs_dirname "$0")"
|
|
||||||
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
|
||||||
export BATS_CWD="$(abs_dirname .)"
|
|
||||||
export PATH="$BATS_LIBEXEC:$PATH"
|
|
||||||
|
|
||||||
options=()
|
|
||||||
arguments=()
|
|
||||||
for arg in "$@"; do
|
|
||||||
if [ "${arg:0:1}" = "-" ]; then
|
|
||||||
if [ "${arg:1:1}" = "-" ]; then
|
|
||||||
options[${#options[*]}]="${arg:2}"
|
|
||||||
else
|
|
||||||
index=1
|
|
||||||
while option="${arg:$index:1}"; do
|
|
||||||
[ -n "$option" ] || break
|
|
||||||
options[${#options[*]}]="$option"
|
|
||||||
let index+=1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
arguments[${#arguments[*]}]="$arg"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
unset count_flag pretty
|
|
||||||
[ -t 0 ] && [ -t 1 ] && pretty="1"
|
|
||||||
[ -n "$CI" ] && pretty=""
|
|
||||||
|
|
||||||
for option in "${options[@]}"; do
|
|
||||||
case "$option" in
|
|
||||||
"h" | "help" )
|
|
||||||
help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"v" | "version" )
|
|
||||||
version
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"c" | "count" )
|
|
||||||
count_flag="-c"
|
|
||||||
;;
|
|
||||||
"t" | "tap" )
|
|
||||||
pretty=""
|
|
||||||
;;
|
|
||||||
"p" | "pretty" )
|
|
||||||
pretty="1"
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
usage >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "${#arguments[@]}" -eq 0 ]; then
|
|
||||||
usage >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
filenames=()
|
|
||||||
for filename in "${arguments[@]}"; do
|
|
||||||
if [ -d "$filename" ]; then
|
|
||||||
shopt -s nullglob
|
|
||||||
for suite_filename in "$(expand_path "$filename")"/*.bats; do
|
|
||||||
filenames["${#filenames[@]}"]="$suite_filename"
|
|
||||||
done
|
|
||||||
shopt -u nullglob
|
|
||||||
else
|
|
||||||
filenames["${#filenames[@]}"]="$(expand_path "$filename")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "${#filenames[@]}" -eq 1 ]; then
|
|
||||||
command="bats-exec-test"
|
|
||||||
else
|
|
||||||
command="bats-exec-suite"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$pretty" ]; then
|
|
||||||
extended_syntax_flag="-x"
|
|
||||||
formatter="bats-format-tap-stream"
|
|
||||||
else
|
|
||||||
extended_syntax_flag=""
|
|
||||||
formatter="cat"
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -o pipefail execfail
|
|
||||||
exec "$command" $count_flag $extended_syntax_flag "${filenames[@]}" | "$formatter"
|
|
|
@ -1,55 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
count_only_flag=""
|
|
||||||
if [ "$1" = "-c" ]; then
|
|
||||||
count_only_flag=1
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
extended_syntax_flag=""
|
|
||||||
if [ "$1" = "-x" ]; then
|
|
||||||
extended_syntax_flag="-x"
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
trap "kill 0; exit 1" int
|
|
||||||
|
|
||||||
count=0
|
|
||||||
for filename in "$@"; do
|
|
||||||
let count+="$(bats-exec-test -c "$filename")"
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$count_only_flag" ]; then
|
|
||||||
echo "$count"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "1..$count"
|
|
||||||
status=0
|
|
||||||
offset=0
|
|
||||||
for filename in "$@"; do
|
|
||||||
index=0
|
|
||||||
{
|
|
||||||
IFS= read -r # 1..n
|
|
||||||
while IFS= read -r line; do
|
|
||||||
case "$line" in
|
|
||||||
"begin "* )
|
|
||||||
let index+=1
|
|
||||||
echo "${line/ $index / $(($offset + $index)) }"
|
|
||||||
;;
|
|
||||||
"ok "* | "not ok "* )
|
|
||||||
[ -n "$extended_syntax_flag" ] || let index+=1
|
|
||||||
echo "${line/ $index / $(($offset + $index)) }"
|
|
||||||
[ "${line:0:6}" != "not ok" ] || status=1
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
echo "$line"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
} < <( bats-exec-test $extended_syntax_flag "$filename" )
|
|
||||||
offset=$(($offset + $index))
|
|
||||||
done
|
|
||||||
|
|
||||||
exit "$status"
|
|
|
@ -1,346 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
set -E
|
|
||||||
set -T
|
|
||||||
|
|
||||||
BATS_COUNT_ONLY=""
|
|
||||||
if [ "$1" = "-c" ]; then
|
|
||||||
BATS_COUNT_ONLY=1
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
BATS_EXTENDED_SYNTAX=""
|
|
||||||
if [ "$1" = "-x" ]; then
|
|
||||||
BATS_EXTENDED_SYNTAX="$1"
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
BATS_TEST_FILENAME="$1"
|
|
||||||
if [ -z "$BATS_TEST_FILENAME" ]; then
|
|
||||||
echo "usage: bats-exec <filename>" >&2
|
|
||||||
exit 1
|
|
||||||
elif [ ! -f "$BATS_TEST_FILENAME" ]; then
|
|
||||||
echo "bats: $BATS_TEST_FILENAME does not exist" >&2
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
BATS_TEST_DIRNAME="$(dirname "$BATS_TEST_FILENAME")"
|
|
||||||
BATS_TEST_NAMES=()
|
|
||||||
|
|
||||||
load() {
|
|
||||||
local name="$1"
|
|
||||||
local filename
|
|
||||||
|
|
||||||
if [ "${name:0:1}" = "/" ]; then
|
|
||||||
filename="${name}"
|
|
||||||
else
|
|
||||||
filename="$BATS_TEST_DIRNAME/${name}.bash"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f "$filename" ] || {
|
|
||||||
echo "bats: $filename does not exist" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
source "${filename}"
|
|
||||||
}
|
|
||||||
|
|
||||||
run() {
|
|
||||||
local e E T oldIFS
|
|
||||||
[[ ! "$-" =~ e ]] || e=1
|
|
||||||
[[ ! "$-" =~ E ]] || E=1
|
|
||||||
[[ ! "$-" =~ T ]] || T=1
|
|
||||||
set +e
|
|
||||||
set +E
|
|
||||||
set +T
|
|
||||||
output="$("$@" 2>&1)"
|
|
||||||
status="$?"
|
|
||||||
oldIFS=$IFS
|
|
||||||
IFS=$'\n' lines=($output)
|
|
||||||
[ -z "$e" ] || set -e
|
|
||||||
[ -z "$E" ] || set -E
|
|
||||||
[ -z "$T" ] || set -T
|
|
||||||
IFS=$oldIFS
|
|
||||||
}
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
skip() {
|
|
||||||
BATS_TEST_SKIPPED=${1:-1}
|
|
||||||
BATS_TEST_COMPLETED=1
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_test_begin() {
|
|
||||||
BATS_TEST_DESCRIPTION="$1"
|
|
||||||
if [ -n "$BATS_EXTENDED_SYNTAX" ]; then
|
|
||||||
echo "begin $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3
|
|
||||||
fi
|
|
||||||
setup
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_test_function() {
|
|
||||||
local test_name="$1"
|
|
||||||
BATS_TEST_NAMES["${#BATS_TEST_NAMES[@]}"]="$test_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_capture_stack_trace() {
|
|
||||||
BATS_PREVIOUS_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" )
|
|
||||||
BATS_CURRENT_STACK_TRACE=()
|
|
||||||
|
|
||||||
local test_pattern=" $BATS_TEST_NAME $BATS_TEST_SOURCE"
|
|
||||||
local setup_pattern=" setup $BATS_TEST_SOURCE"
|
|
||||||
local teardown_pattern=" teardown $BATS_TEST_SOURCE"
|
|
||||||
|
|
||||||
local frame
|
|
||||||
local index=1
|
|
||||||
|
|
||||||
while frame="$(caller "$index")"; do
|
|
||||||
BATS_CURRENT_STACK_TRACE["${#BATS_CURRENT_STACK_TRACE[@]}"]="$frame"
|
|
||||||
if [[ "$frame" = *"$test_pattern" || \
|
|
||||||
"$frame" = *"$setup_pattern" || \
|
|
||||||
"$frame" = *"$teardown_pattern" ]]; then
|
|
||||||
break
|
|
||||||
else
|
|
||||||
let index+=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
BATS_SOURCE="$(bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}")"
|
|
||||||
BATS_LINENO="$(bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}")"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_print_stack_trace() {
|
|
||||||
local frame
|
|
||||||
local index=1
|
|
||||||
local count="${#@}"
|
|
||||||
|
|
||||||
for frame in "$@"; do
|
|
||||||
local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")"
|
|
||||||
local lineno="$(bats_frame_lineno "$frame")"
|
|
||||||
|
|
||||||
if [ $index -eq 1 ]; then
|
|
||||||
echo -n "# ("
|
|
||||||
else
|
|
||||||
echo -n "# "
|
|
||||||
fi
|
|
||||||
|
|
||||||
local fn="$(bats_frame_function "$frame")"
|
|
||||||
if [ "$fn" != "$BATS_TEST_NAME" ]; then
|
|
||||||
echo -n "from function \`$fn' "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $index -eq $count ]; then
|
|
||||||
echo "in test file $filename, line $lineno)"
|
|
||||||
else
|
|
||||||
echo "in file $filename, line $lineno,"
|
|
||||||
fi
|
|
||||||
|
|
||||||
let index+=1
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_print_failed_command() {
|
|
||||||
local frame="$1"
|
|
||||||
local status="$2"
|
|
||||||
local filename="$(bats_frame_filename "$frame")"
|
|
||||||
local lineno="$(bats_frame_lineno "$frame")"
|
|
||||||
|
|
||||||
local failed_line="$(bats_extract_line "$filename" "$lineno")"
|
|
||||||
local failed_command="$(bats_strip_string "$failed_line")"
|
|
||||||
echo -n "# \`${failed_command}' "
|
|
||||||
|
|
||||||
if [ $status -eq 1 ]; then
|
|
||||||
echo "failed"
|
|
||||||
else
|
|
||||||
echo "failed with status $status"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_frame_lineno() {
|
|
||||||
local frame="$1"
|
|
||||||
local lineno="${frame%% *}"
|
|
||||||
echo "$lineno"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_frame_function() {
|
|
||||||
local frame="$1"
|
|
||||||
local rest="${frame#* }"
|
|
||||||
local fn="${rest%% *}"
|
|
||||||
echo "$fn"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_frame_filename() {
|
|
||||||
local frame="$1"
|
|
||||||
local rest="${frame#* }"
|
|
||||||
local filename="${rest#* }"
|
|
||||||
|
|
||||||
if [ "$filename" = "$BATS_TEST_SOURCE" ]; then
|
|
||||||
echo "$BATS_TEST_FILENAME"
|
|
||||||
else
|
|
||||||
echo "$filename"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_extract_line() {
|
|
||||||
local filename="$1"
|
|
||||||
local lineno="$2"
|
|
||||||
sed -n "${lineno}p" "$filename"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_strip_string() {
|
|
||||||
local string="$1"
|
|
||||||
printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_trim_filename() {
|
|
||||||
local filename="$1"
|
|
||||||
local length="${#BATS_CWD}"
|
|
||||||
|
|
||||||
if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then
|
|
||||||
echo "${filename:length+1}"
|
|
||||||
else
|
|
||||||
echo "$filename"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_debug_trap() {
|
|
||||||
if [ "$BASH_SOURCE" != "$1" ]; then
|
|
||||||
bats_capture_stack_trace
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_error_trap() {
|
|
||||||
BATS_ERROR_STATUS="$?"
|
|
||||||
BATS_ERROR_STACK_TRACE=( "${BATS_PREVIOUS_STACK_TRACE[@]}" )
|
|
||||||
trap - debug
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_teardown_trap() {
|
|
||||||
trap "bats_exit_trap" exit
|
|
||||||
local status=0
|
|
||||||
teardown >>"$BATS_OUT" 2>&1 || status="$?"
|
|
||||||
|
|
||||||
if [ $status -eq 0 ]; then
|
|
||||||
BATS_TEARDOWN_COMPLETED=1
|
|
||||||
elif [ -n "$BATS_TEST_COMPLETED" ]; then
|
|
||||||
BATS_ERROR_STATUS="$status"
|
|
||||||
BATS_ERROR_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" )
|
|
||||||
fi
|
|
||||||
|
|
||||||
bats_exit_trap
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_exit_trap() {
|
|
||||||
local status
|
|
||||||
local skipped
|
|
||||||
trap - err exit
|
|
||||||
|
|
||||||
skipped=""
|
|
||||||
if [ -n "$BATS_TEST_SKIPPED" ]; then
|
|
||||||
skipped=" # skip"
|
|
||||||
if [ "1" != "$BATS_TEST_SKIPPED" ]; then
|
|
||||||
skipped+=" ($BATS_TEST_SKIPPED)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$BATS_TEST_COMPLETED" ] || [ -z "$BATS_TEARDOWN_COMPLETED" ]; then
|
|
||||||
echo "not ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3
|
|
||||||
bats_print_stack_trace "${BATS_ERROR_STACK_TRACE[@]}" >&3
|
|
||||||
bats_print_failed_command "${BATS_ERROR_STACK_TRACE[${#BATS_ERROR_STACK_TRACE[@]}-1]}" "$BATS_ERROR_STATUS" >&3
|
|
||||||
sed -e "s/^/# /" < "$BATS_OUT" >&3
|
|
||||||
status=1
|
|
||||||
else
|
|
||||||
echo "ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}" >&3
|
|
||||||
status=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$BATS_OUT"
|
|
||||||
exit "$status"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_perform_tests() {
|
|
||||||
echo "1..$#"
|
|
||||||
test_number=1
|
|
||||||
status=0
|
|
||||||
for test_name in "$@"; do
|
|
||||||
"$0" $BATS_EXTENDED_SYNTAX "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1
|
|
||||||
let test_number+=1
|
|
||||||
done
|
|
||||||
exit "$status"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_perform_test() {
|
|
||||||
BATS_TEST_NAME="$1"
|
|
||||||
if [ "$(type -t "$BATS_TEST_NAME" || true)" = "function" ]; then
|
|
||||||
BATS_TEST_NUMBER="$2"
|
|
||||||
if [ -z "$BATS_TEST_NUMBER" ]; then
|
|
||||||
echo "1..1"
|
|
||||||
BATS_TEST_NUMBER="1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
BATS_TEST_COMPLETED=""
|
|
||||||
BATS_TEARDOWN_COMPLETED=""
|
|
||||||
trap "bats_debug_trap \"\$BASH_SOURCE\"" debug
|
|
||||||
trap "bats_error_trap" err
|
|
||||||
trap "bats_teardown_trap" exit
|
|
||||||
"$BATS_TEST_NAME" >>"$BATS_OUT" 2>&1
|
|
||||||
BATS_TEST_COMPLETED=1
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "bats: unknown test name \`$BATS_TEST_NAME'" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$TMPDIR" ]; then
|
|
||||||
BATS_TMPDIR="/tmp"
|
|
||||||
else
|
|
||||||
BATS_TMPDIR="${TMPDIR%/}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
BATS_TMPNAME="$BATS_TMPDIR/bats.$$"
|
|
||||||
BATS_PARENT_TMPNAME="$BATS_TMPDIR/bats.$PPID"
|
|
||||||
BATS_OUT="${BATS_TMPNAME}.out"
|
|
||||||
|
|
||||||
bats_preprocess_source() {
|
|
||||||
BATS_TEST_SOURCE="${BATS_TMPNAME}.src"
|
|
||||||
{ tr -d '\r' < "$BATS_TEST_FILENAME"; echo; } | bats-preprocess > "$BATS_TEST_SOURCE"
|
|
||||||
trap "bats_cleanup_preprocessed_source" err exit
|
|
||||||
trap "bats_cleanup_preprocessed_source; exit 1" int
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_cleanup_preprocessed_source() {
|
|
||||||
rm -f "$BATS_TEST_SOURCE"
|
|
||||||
}
|
|
||||||
|
|
||||||
bats_evaluate_preprocessed_source() {
|
|
||||||
if [ -z "$BATS_TEST_SOURCE" ]; then
|
|
||||||
BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src"
|
|
||||||
fi
|
|
||||||
source "$BATS_TEST_SOURCE"
|
|
||||||
}
|
|
||||||
|
|
||||||
exec 3<&1
|
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]; then
|
|
||||||
bats_preprocess_source
|
|
||||||
bats_evaluate_preprocessed_source
|
|
||||||
|
|
||||||
if [ -n "$BATS_COUNT_ONLY" ]; then
|
|
||||||
echo "${#BATS_TEST_NAMES[@]}"
|
|
||||||
else
|
|
||||||
bats_perform_tests "${BATS_TEST_NAMES[@]}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
bats_evaluate_preprocessed_source
|
|
||||||
bats_perform_test "$@"
|
|
||||||
fi
|
|
|
@ -1,165 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Just stream the TAP output (sans extended syntax) if tput is missing
|
|
||||||
command -v tput >/dev/null || exec grep -v "^begin "
|
|
||||||
|
|
||||||
header_pattern='[0-9]+\.\.[0-9]+'
|
|
||||||
IFS= read -r header
|
|
||||||
|
|
||||||
if [[ "$header" =~ $header_pattern ]]; then
|
|
||||||
count="${header:3}"
|
|
||||||
index=0
|
|
||||||
failures=0
|
|
||||||
skipped=0
|
|
||||||
name=""
|
|
||||||
count_column_width=$(( ${#count} * 2 + 2 ))
|
|
||||||
else
|
|
||||||
# If the first line isn't a TAP plan, print it and pass the rest through
|
|
||||||
printf "%s\n" "$header"
|
|
||||||
exec cat
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_screen_width() {
|
|
||||||
screen_width="$(tput cols)"
|
|
||||||
count_column_left=$(( $screen_width - $count_column_width ))
|
|
||||||
}
|
|
||||||
|
|
||||||
trap update_screen_width WINCH
|
|
||||||
update_screen_width
|
|
||||||
|
|
||||||
begin() {
|
|
||||||
go_to_column 0
|
|
||||||
printf_with_truncation $(( $count_column_left - 1 )) " %s" "$name"
|
|
||||||
clear_to_end_of_line
|
|
||||||
go_to_column $count_column_left
|
|
||||||
printf "%${#count}s/${count}" "$index"
|
|
||||||
go_to_column 1
|
|
||||||
}
|
|
||||||
|
|
||||||
pass() {
|
|
||||||
go_to_column 0
|
|
||||||
printf " ✓ %s" "$name"
|
|
||||||
advance
|
|
||||||
}
|
|
||||||
|
|
||||||
skip() {
|
|
||||||
local reason="$1"
|
|
||||||
[ -z "$reason" ] || reason=": $reason"
|
|
||||||
go_to_column 0
|
|
||||||
printf " - %s (skipped%s)" "$name" "$reason"
|
|
||||||
advance
|
|
||||||
}
|
|
||||||
|
|
||||||
fail() {
|
|
||||||
go_to_column 0
|
|
||||||
set_color 1 bold
|
|
||||||
printf " ✗ %s" "$name"
|
|
||||||
advance
|
|
||||||
}
|
|
||||||
|
|
||||||
log() {
|
|
||||||
set_color 1
|
|
||||||
printf " %s\n" "$1"
|
|
||||||
clear_color
|
|
||||||
}
|
|
||||||
|
|
||||||
summary() {
|
|
||||||
printf "\n%d test%s" "$count" "$(plural "$count")"
|
|
||||||
|
|
||||||
printf ", %d failure%s" "$failures" "$(plural "$failures")"
|
|
||||||
|
|
||||||
if [ "$skipped" -gt 0 ]; then
|
|
||||||
printf ", %d skipped" "$skipped"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
printf_with_truncation() {
|
|
||||||
local width="$1"
|
|
||||||
shift
|
|
||||||
local string="$(printf "$@")"
|
|
||||||
|
|
||||||
if [ "${#string}" -gt "$width" ]; then
|
|
||||||
printf "%s..." "${string:0:$(( $width - 4 ))}"
|
|
||||||
else
|
|
||||||
printf "%s" "$string"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
go_to_column() {
|
|
||||||
local column="$1"
|
|
||||||
printf "\x1B[%dG" $(( $column + 1 ))
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_to_end_of_line() {
|
|
||||||
printf "\x1B[K"
|
|
||||||
}
|
|
||||||
|
|
||||||
advance() {
|
|
||||||
clear_to_end_of_line
|
|
||||||
echo
|
|
||||||
clear_color
|
|
||||||
}
|
|
||||||
|
|
||||||
set_color() {
|
|
||||||
local color="$1"
|
|
||||||
local weight="$2"
|
|
||||||
printf "\x1B[%d;%dm" $(( 30 + $color )) "$( [ "$weight" = "bold" ] && echo 1 || echo 22 )"
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_color() {
|
|
||||||
printf "\x1B[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
plural() {
|
|
||||||
[ "$1" -eq 1 ] || echo "s"
|
|
||||||
}
|
|
||||||
|
|
||||||
_buffer=""
|
|
||||||
|
|
||||||
buffer() {
|
|
||||||
_buffer="${_buffer}$("$@")"
|
|
||||||
}
|
|
||||||
|
|
||||||
flush() {
|
|
||||||
printf "%s" "$_buffer"
|
|
||||||
_buffer=""
|
|
||||||
}
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
flush
|
|
||||||
printf "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
trap finish EXIT
|
|
||||||
|
|
||||||
while IFS= read -r line; do
|
|
||||||
case "$line" in
|
|
||||||
"begin "* )
|
|
||||||
let index+=1
|
|
||||||
name="${line#* $index }"
|
|
||||||
buffer begin
|
|
||||||
flush
|
|
||||||
;;
|
|
||||||
"ok "* )
|
|
||||||
skip_expr="ok $index # skip (\(([^)]*)\))?"
|
|
||||||
if [[ "$line" =~ $skip_expr ]]; then
|
|
||||||
let skipped+=1
|
|
||||||
buffer skip "${BASH_REMATCH[2]}"
|
|
||||||
else
|
|
||||||
buffer pass
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"not ok "* )
|
|
||||||
let failures+=1
|
|
||||||
buffer fail
|
|
||||||
;;
|
|
||||||
"# "* )
|
|
||||||
buffer log "${line:2}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
buffer summary
|
|
|
@ -1,52 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
encode_name() {
|
|
||||||
local name="$1"
|
|
||||||
local result="test_"
|
|
||||||
|
|
||||||
if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then
|
|
||||||
name="${name//_/-5f}"
|
|
||||||
name="${name//-/-2d}"
|
|
||||||
name="${name// /_}"
|
|
||||||
result+="$name"
|
|
||||||
else
|
|
||||||
local length="${#name}"
|
|
||||||
local char i
|
|
||||||
|
|
||||||
for ((i=0; i<length; i++)); do
|
|
||||||
char="${name:$i:1}"
|
|
||||||
if [ "$char" = " " ]; then
|
|
||||||
result+="_"
|
|
||||||
elif [[ "$char" =~ [[:alnum:]] ]]; then
|
|
||||||
result+="$char"
|
|
||||||
else
|
|
||||||
result+="$(printf -- "-%02x" \'"$char")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$result"
|
|
||||||
}
|
|
||||||
|
|
||||||
tests=()
|
|
||||||
index=0
|
|
||||||
pattern='^ *@test *([^ ].*) *\{ *(.*)$'
|
|
||||||
|
|
||||||
while IFS= read -r line; do
|
|
||||||
let index+=1
|
|
||||||
if [[ "$line" =~ $pattern ]]; then
|
|
||||||
quoted_name="${BASH_REMATCH[1]}"
|
|
||||||
body="${BASH_REMATCH[2]}"
|
|
||||||
name="$(eval echo "$quoted_name")"
|
|
||||||
encoded_name="$(encode_name "$name")"
|
|
||||||
tests["${#tests[@]}"]="$encoded_name"
|
|
||||||
echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}"
|
|
||||||
else
|
|
||||||
printf "%s\n" "$line"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for test_name in "${tests[@]}"; do
|
|
||||||
echo "bats_test_function ${test_name}"
|
|
||||||
done
|
|
|
@ -1,4 +1,4 @@
|
||||||
poll pop3.example.com with proto POP3
|
poll pop3.example.tld with proto POP3
|
||||||
user 'username' there with
|
user 'username' there with
|
||||||
password 'secret'
|
password 'secret'
|
||||||
is 'user2@domain.tld'
|
is 'user2@domain.tld'
|
||||||
|
|
334
test/tests.bats
334
test/tests.bats
|
@ -1,10 +1,13 @@
|
||||||
|
load 'test_helper/bats-support/load'
|
||||||
|
load 'test_helper/bats-assert/load'
|
||||||
|
|
||||||
#
|
#
|
||||||
# configuration checks
|
# configuration checks
|
||||||
#
|
#
|
||||||
|
|
||||||
@test "checking configuration: hostname/domainname" {
|
@test "checking configuration: hostname/domainname" {
|
||||||
run docker run `docker inspect --format '{{ .Config.Image }}' mail`
|
run docker run `docker inspect --format '{{ .Config.Image }}' mail`
|
||||||
[ "$status" -eq 1 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -13,28 +16,28 @@
|
||||||
|
|
||||||
@test "checking process: postfix" {
|
@test "checking process: postfix" {
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/postfix/master'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/postfix/master'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: amavisd-new" {
|
@test "checking process: amavisd-new" {
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/amavisd-new'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/amavisd-new'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: opendkim" {
|
@test "checking process: opendkim" {
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/opendkim'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/opendkim'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: opendmarc" {
|
@test "checking process: opendmarc" {
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/opendmarc'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/opendmarc'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: clamav (disabled by ENABLE_CLAMAV=0)" {
|
@test "checking process: clamav (disabled by ENABLE_CLAMAV=0)" {
|
||||||
if [ $ENABLE_CLAMAV -eq 0 ]; then
|
if [ $ENABLE_CLAMAV -eq 0 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
elif [ $ENABLE_CLAMAV -eq 1 ]; then
|
elif [ $ENABLE_CLAMAV -eq 1 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -45,14 +48,14 @@
|
||||||
skip
|
skip
|
||||||
elif [ $ENABLE_CLAMAV -eq 1 ]; then
|
elif [ $ENABLE_CLAMAV -eq 1 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/clamd'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: fail2ban (disabled by ENABLE_FAIL2BAN=0)" {
|
@test "checking process: fail2ban (disabled by ENABLE_FAIL2BAN=0)" {
|
||||||
if [ $ENABLE_FAIL2BAN -eq 0 ]; then
|
if [ $ENABLE_FAIL2BAN -eq 0 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/python /usr/bin/fail2ban-server'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/python /usr/bin/fail2ban-server'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
elif [ $ENABLE_FAIL2BAN -eq 1 ]; then
|
elif [ $ENABLE_FAIL2BAN -eq 1 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -63,14 +66,14 @@
|
||||||
skip
|
skip
|
||||||
elif [ $ENABLE_FAIL2BAN -eq 1 ]; then
|
elif [ $ENABLE_FAIL2BAN -eq 1 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/python /usr/bin/fail2ban-server'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/python /usr/bin/fail2ban-server'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: fetchmail (disabled by ENABLE_FETCHMAIL=0)" {
|
@test "checking process: fetchmail (disabled by ENABLE_FETCHMAIL=0)" {
|
||||||
if [ $ENABLE_FETCHMAIL -eq 0 ]; then
|
if [ $ENABLE_FETCHMAIL -eq 0 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/fetchmail'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/fetchmail'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
elif [ $ENABLE_FETCHMAIL -eq 1 ]; then
|
elif [ $ENABLE_FETCHMAIL -eq 1 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -80,15 +83,15 @@
|
||||||
if [ $ENABLE_FETCHMAIL -eq 0 ]; then
|
if [ $ENABLE_FETCHMAIL -eq 0 ]; then
|
||||||
skip
|
skip
|
||||||
elif [ $ENABLE_FETCHMAIL -eq 1 ]; then
|
elif [ $ENABLE_FETCHMAIL -eq 1 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/fetchmail'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/bin/fetchmail'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking process: saslauthd (enabled by ENABLE_SASLAUTHD=0)" {
|
@test "checking process: saslauthd (disabled by ENABLE_SASLAUTHD=0)" {
|
||||||
if [ $ENABLE_SASLAUTHD -eq 0 ]; then
|
if [ $ENABLE_SASLAUTHD -eq 0 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
elif [ $ENABLE_SASLAUTHD -eq 1 ]; then
|
elif [ $ENABLE_SASLAUTHD -eq 1 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -99,7 +102,7 @@
|
||||||
skip
|
skip
|
||||||
elif [ $ENABLE_SASLAUTHD -eq 1 ]; then
|
elif [ $ENABLE_SASLAUTHD -eq 1 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +113,7 @@
|
||||||
@test "checking process: dovecot imaplogin (enabled in default configuration)" {
|
@test "checking process: dovecot imaplogin (enabled in default configuration)" {
|
||||||
if [ $SMTP_ONLY -eq 0 ]; then
|
if [ $SMTP_ONLY -eq 0 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
elif [ $SMTP_ONLY -eq 1 ]; then
|
elif [ $SMTP_ONLY -eq 1 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -121,7 +124,7 @@
|
||||||
skip
|
skip
|
||||||
elif [ $SMTP_ONLY -eq 1 ]; then
|
elif [ $SMTP_ONLY -eq 1 ]; then
|
||||||
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'"
|
run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +133,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/bash -c "nc -w 2 0.0.0.0 143 | grep '* OK' | grep 'STARTTLS' | grep 'ready'"
|
run docker exec mail /bin/bash -c "nc -w 2 0.0.0.0 143 | grep '* OK' | grep 'STARTTLS' | grep 'ready'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking imap: authentication works" {
|
@test "checking imap: authentication works" {
|
||||||
|
@ -138,7 +141,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt"
|
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -150,7 +153,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'"
|
run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking pop: authentication works" {
|
@test "checking pop: authentication works" {
|
||||||
|
@ -158,7 +161,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt"
|
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -170,7 +173,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld mypassword | grep 'auth succeeded'"
|
run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld mypassword | grep 'auth succeeded'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking sasl: doveadm auth test fails with bad password" {
|
@test "checking sasl: doveadm auth test fails with bad password" {
|
||||||
|
@ -178,7 +181,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld BADPASSWORD | grep 'auth failed'"
|
run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld BADPASSWORD | grep 'auth failed'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking sasl: sasl_passwd exists" {
|
@test "checking sasl: sasl_passwd exists" {
|
||||||
|
@ -186,7 +189,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail [ -f /etc/postfix/sasl_passwd ]
|
run docker exec mail [ -f /etc/postfix/sasl_passwd ]
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -195,8 +198,8 @@
|
||||||
|
|
||||||
@test "checking logs: mail related logs should be located in a subdirectory" {
|
@test "checking logs: mail related logs should be located in a subdirectory" {
|
||||||
run docker exec mail /bin/sh -c "ls -1 /var/log/mail/ | grep -E 'clamav|freshclam|mail'|wc -l"
|
run docker exec mail /bin/sh -c "ls -1 /var/log/mail/ | grep -E 'clamav|freshclam|mail'|wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ "$output" > 2 ]
|
[ "$output" -ge 3 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -205,64 +208,57 @@
|
||||||
|
|
||||||
@test "checking smtp: authentication works with good password (plain)" {
|
@test "checking smtp: 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/smtp-auth-plain.txt | grep 'Authentication successful'"
|
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-plain.txt | grep 'Authentication successful'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: authentication fails with wrong password (plain)" {
|
@test "checking smtp: 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/smtp-auth-plain-wrong.txt | grep 'authentication failed'"
|
run docker exec mail /bin/sh -c "nc -w 20 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-plain-wrong.txt | grep 'authentication failed'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: authentication works with good password (login)" {
|
@test "checking smtp: 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/smtp-auth-login.txt | grep 'Authentication successful'"
|
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt | grep 'Authentication successful'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: authentication fails with wrong password (login)" {
|
@test "checking smtp: 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/smtp-auth-login-wrong.txt | grep 'authentication failed'"
|
run docker exec mail /bin/sh -c "nc -w 20 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt | grep 'authentication failed'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: delivers mail to existing account" {
|
@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"
|
run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 6
|
||||||
[ "$output" -eq 6 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: delivers mail to existing alias" {
|
@test "checking smtp: delivers mail to existing alias" {
|
||||||
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<alias1@localhost.localdomain>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<alias1@localhost.localdomain>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: delivers mail to existing catchall" {
|
@test "checking smtp: delivers mail to existing catchall" {
|
||||||
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<wildcard@localdomain2.com>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<wildcard@localdomain2.com>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: delivers mail to regexp alias" {
|
@test "checking smtp: delivers mail to regexp alias" {
|
||||||
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<test123@localhost.localdomain>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
run docker exec mail /bin/sh -c "grep 'to=<user1@localhost.localdomain>, orig_to=<test123@localhost.localdomain>' /var/log/mail/mail.log | grep 'status=sent' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: user1 should have received 5 mails" {
|
@test "checking smtp: user1 should have received 5 mails" {
|
||||||
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/new | wc -l"
|
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/new | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 5
|
||||||
[ "$output" = 5 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: rejects mail to unknown user" {
|
@test "checking smtp: rejects mail to unknown user" {
|
||||||
run docker exec mail /bin/sh -c "grep '<nouser@localhost.localdomain>: Recipient address rejected: User unknown in virtual mailbox table' /var/log/mail/mail.log | wc -l"
|
run docker exec mail /bin/sh -c "grep '<nouser@localhost.localdomain>: Recipient address rejected: User unknown in virtual mailbox table' /var/log/mail/mail.log | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: redirects mail to external aliases" {
|
@test "checking smtp: redirects mail to external aliases" {
|
||||||
run docker exec mail /bin/sh -c "grep -- '-> <external1@otherdomain.tld>' /var/log/mail/mail.log | wc -l"
|
run docker exec mail /bin/sh -c "grep -- '-> <external1@otherdomain.tld>' /var/log/mail/mail.log | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" = 2 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: rejects spam" {
|
@test "checking smtp: rejects spam" {
|
||||||
|
@ -270,8 +266,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep 'Blocked SPAM' /var/log/mail/mail.log | grep spam@external.tld | wc -l"
|
run docker exec mail /bin/sh -c "grep 'Blocked SPAM' /var/log/mail/mail.log | grep spam@external.tld | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: rejects virus" {
|
@test "checking smtp: rejects virus" {
|
||||||
|
@ -279,8 +274,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep 'Blocked INFECTED' /var/log/mail/mail.log | grep virus@external.tld | wc -l"
|
run docker exec mail /bin/sh -c "grep 'Blocked INFECTED' /var/log/mail/mail.log | grep virus@external.tld | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -289,21 +283,19 @@
|
||||||
|
|
||||||
@test "checking accounts: user accounts" {
|
@test "checking accounts: user accounts" {
|
||||||
run docker exec mail doveadm user '*'
|
run docker exec mail doveadm user '*'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ "${lines[0]}" = "user1@localhost.localdomain" ]
|
[ "${lines[0]}" = "user1@localhost.localdomain" ]
|
||||||
[ "${lines[1]}" = "user2@otherdomain.tld" ]
|
[ "${lines[1]}" = "user2@otherdomain.tld" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking accounts: user mail folders for user1" {
|
@test "checking accounts: user mail folders for user1" {
|
||||||
run docker exec mail /bin/bash -c "ls -A /var/mail/localhost.localdomain/user1 | grep -E '.Drafts|.Sent|.Trash|cur|new|subscriptions|tmp' | wc -l"
|
run docker exec mail /bin/bash -c "ls -A /var/mail/localhost.localdomain/user1 | grep -E '.Drafts|.Sent|.Trash|cur|new|subscriptions|tmp' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 7
|
||||||
[ "$output" -eq 7 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking accounts: user mail folders for user2" {
|
@test "checking accounts: user mail folders for user2" {
|
||||||
run docker exec mail /bin/bash -c "ls -A /var/mail/otherdomain.tld/user2 | grep -E '.Drafts|.Sent|.Trash|cur|new|subscriptions|tmp' | wc -l"
|
run docker exec mail /bin/bash -c "ls -A /var/mail/otherdomain.tld/user2 | grep -E '.Drafts|.Sent|.Trash|cur|new|subscriptions|tmp' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 7
|
||||||
[ "$output" -eq 7 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -312,7 +304,7 @@
|
||||||
|
|
||||||
@test "checking postfix: vhost file is correct" {
|
@test "checking postfix: vhost file is correct" {
|
||||||
run docker exec mail cat /etc/postfix/vhost
|
run docker exec mail cat /etc/postfix/vhost
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ "${lines[0]}" = "localdomain2.com" ]
|
[ "${lines[0]}" = "localdomain2.com" ]
|
||||||
[ "${lines[1]}" = "localhost.localdomain" ]
|
[ "${lines[1]}" = "localhost.localdomain" ]
|
||||||
[ "${lines[2]}" = "otherdomain.tld" ]
|
[ "${lines[2]}" = "otherdomain.tld" ]
|
||||||
|
@ -320,9 +312,9 @@
|
||||||
|
|
||||||
@test "checking postfix: main.cf overrides" {
|
@test "checking postfix: main.cf overrides" {
|
||||||
run docker exec mail grep -q 'max_idle = 600s' /tmp/docker-mailserver/postfix-main.cf
|
run docker exec mail grep -q 'max_idle = 600s' /tmp/docker-mailserver/postfix-main.cf
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail grep -q 'readme_directory = /tmp' /tmp/docker-mailserver/postfix-main.cf
|
run docker exec mail grep -q 'readme_directory = /tmp' /tmp/docker-mailserver/postfix-main.cf
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -331,10 +323,9 @@
|
||||||
|
|
||||||
@test "checking dovecot: config additions" {
|
@test "checking dovecot: config additions" {
|
||||||
run docker exec mail grep -q 'mail_max_userip_connections = 69' /tmp/docker-mailserver/dovecot.cf
|
run docker exec mail grep -q 'mail_max_userip_connections = 69' /tmp/docker-mailserver/dovecot.cf
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "doveconf | grep 'mail_max_userip_connections = 69'"
|
run docker exec mail /bin/sh -c "doveconf | grep 'mail_max_userip_connections = 69'"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 'mail_max_userip_connections = 69'
|
||||||
[ "$output" = 'mail_max_userip_connections = 69' ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -346,7 +337,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
run docker exec mail /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking spamassassin: should not be listed in amavis when disabled" {
|
@test "checking spamassassin: should not be listed in amavis when disabled" {
|
||||||
|
@ -354,7 +345,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
run docker exec mail /bin/sh -c "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking spamassassin: docker env variables are set correctly (default)" {
|
@test "checking spamassassin: docker env variables are set correctly (default)" {
|
||||||
|
@ -362,11 +353,11 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
run docker exec mail /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking spamassassin: docker env variables are set correctly (custom)" {
|
@test "checking spamassassin: docker env variables are set correctly (custom)" {
|
||||||
|
@ -374,11 +365,11 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 1.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 1.0'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -390,7 +381,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
run docker exec mail grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking clamav: should not be listed in amavis when disabled" {
|
@test "checking clamav: should not be listed in amavis when disabled" {
|
||||||
|
@ -398,7 +389,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
run docker exec mail grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking clamav: should not be called when disabled" {
|
@test "checking clamav: should not be called when disabled" {
|
||||||
|
@ -406,7 +397,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
run docker exec mail grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -415,14 +406,12 @@
|
||||||
|
|
||||||
@test "checking opendkim: /etc/opendkim/KeyTable should contain 2 entries" {
|
@test "checking opendkim: /etc/opendkim/KeyTable should contain 2 entries" {
|
||||||
run docker exec mail /bin/sh -c "cat /etc/opendkim/KeyTable | wc -l"
|
run docker exec mail /bin/sh -c "cat /etc/opendkim/KeyTable | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking opendkim: /etc/opendkim/keys/ should contain 2 entries" {
|
@test "checking opendkim: /etc/opendkim/keys/ should contain 2 entries" {
|
||||||
run docker exec mail /bin/sh -c "ls -l /etc/opendkim/keys/ | grep '^d' | wc -l"
|
run docker exec mail /bin/sh -c "ls -l /etc/opendkim/keys/ | grep '^d' | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking opendkim: generator creates keys, tables and TrustedHosts" {
|
@test "checking opendkim: generator creates keys, tables and TrustedHosts" {
|
||||||
|
@ -432,26 +421,22 @@
|
||||||
-v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \
|
-v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \
|
||||||
-v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \
|
-v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 6
|
||||||
[ "$output" -eq 6 ]
|
|
||||||
# Check keys for localhost.localdomain
|
# Check keys for localhost.localdomain
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
# Check keys for otherdomain.tld
|
# Check keys for otherdomain.tld
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
# Check presence of tables and TrustedHosts
|
# Check presence of tables and TrustedHosts
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 4
|
||||||
[ "$output" -eq 4 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-accounts.cf" {
|
@test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-accounts.cf" {
|
||||||
|
@ -460,26 +445,23 @@
|
||||||
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
||||||
-v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \
|
-v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 5
|
||||||
[ "$output" -eq 5 ]
|
|
||||||
# Check keys for localhost.localdomain
|
# Check keys for localhost.localdomain
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
# Check keys for otherdomain.tld
|
# Check keys for otherdomain.tld
|
||||||
# run docker run --rm \
|
# run docker run --rm \
|
||||||
# -v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
# -v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
||||||
# `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
# `docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
||||||
# [ "$status" -eq 0 ]
|
# assert
|
||||||
# [ "$output" -eq 0 ]
|
# [ "$output" -eq 0 ]
|
||||||
# Check presence of tables and TrustedHosts
|
# Check presence of tables and TrustedHosts
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/without-accounts/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 4
|
||||||
[ "$output" -eq 4 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-virtual.cf" {
|
@test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-virtual.cf" {
|
||||||
|
@ -488,26 +470,22 @@
|
||||||
-v "$(pwd)/test/config/without-virtual/":/tmp/docker-mailserver/ \
|
-v "$(pwd)/test/config/without-virtual/":/tmp/docker-mailserver/ \
|
||||||
-v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \
|
-v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 5
|
||||||
[ "$output" -eq 5 ]
|
|
||||||
# Check keys for localhost.localdomain
|
# Check keys for localhost.localdomain
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
# Check keys for otherdomain.tld
|
# Check keys for otherdomain.tld
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
# Check presence of tables and TrustedHosts
|
# Check presence of tables and TrustedHosts
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
-v "$(pwd)/test/config/without-virtual/opendkim":/etc/opendkim \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 4
|
||||||
[ "$output" -eq 4 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -519,22 +497,20 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 0 (ok)'"
|
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 0 (ok)'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking ssl: lets-encrypt-x3-cross-signed.pem is installed" {
|
@test "checking ssl: lets-encrypt-x3-cross-signed.pem is installed" {
|
||||||
run docker exec mail grep 'BEGIN CERTIFICATE' /etc/ssl/certs/lets-encrypt-x3-cross-signed.pem
|
run docker exec mail grep 'BEGIN CERTIFICATE' /etc/ssl/certs/lets-encrypt-x3-cross-signed.pem
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking ssl: letsencrypt configuration is correct" {
|
@test "checking ssl: letsencrypt configuration is correct" {
|
||||||
if [ $SSL_TYPE = "letsencrypt" ]; then
|
if [ $SSL_TYPE = "letsencrypt" ]; then
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/letsencrypt/live/mail.my-domain.com/" /etc/postfix/main.cf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/letsencrypt/live/mail.my-domain.com/" /etc/postfix/main.cf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/letsencrypt/live/mail.my-domain.com/" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/letsencrypt/live/mail.my-domain.com/" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 2
|
||||||
[ "$output" -eq 2 ]
|
|
||||||
else
|
else
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -543,7 +519,7 @@
|
||||||
@test "checking ssl: letsencrypt cert works correctly" {
|
@test "checking ssl: letsencrypt cert works correctly" {
|
||||||
if [ $SSL_TYPE = "letsencrypt" ]; then
|
if [ $SSL_TYPE = "letsencrypt" ]; then
|
||||||
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 10 (certificate has expired)'"
|
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 10 (certificate has expired)'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
else
|
else
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -552,17 +528,13 @@
|
||||||
@test "checking ssl: manual configuration is correct" {
|
@test "checking ssl: manual configuration is correct" {
|
||||||
if [ $SSL_TYPE = "manual" ]; then
|
if [ $SSL_TYPE = "manual" ]; then
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/cert" /etc/postfix/main.cf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/cert" /etc/postfix/main.cf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/cert" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/cert" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/key" /etc/postfix/main.cf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/key" /etc/postfix/main.cf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/key" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
run docker exec mail /bin/sh -c 'grep -ir "/etc/postfix/ssl/key" /etc/dovecot/conf.d/10-ssl.conf | wc -l'
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
else
|
else
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -571,9 +543,9 @@
|
||||||
@test "checking ssl: manual configuration copied files correctly " {
|
@test "checking ssl: manual configuration copied files correctly " {
|
||||||
if [ $SSL_TYPE = "manual" ]; then
|
if [ $SSL_TYPE = "manual" ]; then
|
||||||
run docker exec mail /bin/sh -c 'cmp -s /etc/postfix/ssl/cert /tmp/docker-mailserver/letsencrypt/mail.my-domain.com/fullchain.pem'
|
run docker exec mail /bin/sh -c 'cmp -s /etc/postfix/ssl/cert /tmp/docker-mailserver/letsencrypt/mail.my-domain.com/fullchain.pem'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c 'cmp -s /etc/postfix/ssl/key /tmp/docker-mailserver/letsencrypt/mail.my-domain.com/privkey.pem'
|
run docker exec mail /bin/sh -c 'cmp -s /etc/postfix/ssl/key /tmp/docker-mailserver/letsencrypt/mail.my-domain.com/privkey.pem'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
else
|
else
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -582,7 +554,7 @@
|
||||||
@test "checking ssl: manual cert works correctly" {
|
@test "checking ssl: manual cert works correctly" {
|
||||||
if [ $SSL_TYPE = "manual" ]; then
|
if [ $SSL_TYPE = "manual" ]; then
|
||||||
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 10 (certificate has expired)'"
|
run docker exec mail /bin/sh -c "timeout 1 openssl s_client -connect 0.0.0.0:587 -starttls smtp -CApath /etc/ssl/certs/ | grep 'Verify return code: 10 (certificate has expired)'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
else
|
else
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
@ -597,9 +569,9 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep 'IP list:.*127.0.0.1'"
|
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep 'IP list:.*127.0.0.1'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail /bin/sh -c "grep 'ignoreip = 127.0.0.1/8' /etc/fail2ban/jail.conf"
|
run docker exec mail /bin/sh -c "grep 'ignoreip = 127.0.0.1/8' /etc/fail2ban/jail.conf"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking fail2ban: fail2ban-jail.cf overrides" {
|
@test "checking fail2ban: fail2ban-jail.cf overrides" {
|
||||||
|
@ -610,13 +582,13 @@
|
||||||
|
|
||||||
for FILTER in "${FILTERS[@]}"; do
|
for FILTER in "${FILTERS[@]}"; do
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER bantime"
|
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER bantime"
|
||||||
[ "$output" = 1234 ]
|
assert_output 1234
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER findtime"
|
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER findtime"
|
||||||
[ "$output" = 321 ]
|
assert_output 321
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER maxretry"
|
run docker exec mail /bin/sh -c "fail2ban-client get $FILTER maxretry"
|
||||||
[ "$output" = 2 ]
|
assert_output 2
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,11 +611,11 @@
|
||||||
FAIL_AUTH_MAILER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' fail-auth-mailer)
|
FAIL_AUTH_MAILER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' fail-auth-mailer)
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep '$FAIL_AUTH_MAILER_IP'"
|
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep '$FAIL_AUTH_MAILER_IP'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
|
|
||||||
# Checking that FAIL_AUTH_MAILER_IP is banned by iptables
|
# Checking that FAIL_AUTH_MAILER_IP is banned by iptables
|
||||||
run docker exec mail /bin/sh -c "iptables -L f2b-postfix-sasl -n | grep REJECT | grep '$FAIL_AUTH_MAILER_IP'"
|
run docker exec mail /bin/sh -c "iptables -L f2b-postfix-sasl -n | grep REJECT | grep '$FAIL_AUTH_MAILER_IP'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking fail2ban: unban ip works" {
|
@test "checking fail2ban: unban ip works" {
|
||||||
|
@ -657,11 +629,11 @@
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep 'IP list:.*$FAIL_AUTH_MAILER_IP'"
|
run docker exec mail /bin/sh -c "fail2ban-client status postfix-sasl | grep 'IP list:.*$FAIL_AUTH_MAILER_IP'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
|
|
||||||
# Checking that FAIL_AUTH_MAILER_IP is unbanned by iptables
|
# Checking that FAIL_AUTH_MAILER_IP is unbanned by iptables
|
||||||
run docker exec mail /bin/sh -c "iptables -L f2b-postfix-sasl -n | grep REJECT | grep '$FAIL_AUTH_MAILER_IP'"
|
run docker exec mail /bin/sh -c "iptables -L f2b-postfix-sasl -n | grep REJECT | grep '$FAIL_AUTH_MAILER_IP'"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -673,7 +645,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail grep 'set syslog' /etc/fetchmailrc
|
run docker exec mail grep 'set syslog' /etc/fetchmailrc
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking fetchmail: fetchmail.cf is loaded" {
|
@test "checking fetchmail: fetchmail.cf is loaded" {
|
||||||
|
@ -681,7 +653,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail grep 'pop3.example.tld' /etc/fetchmailrc
|
run docker exec mail grep 'pop3.example.tld' /etc/fetchmailrc
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -690,72 +662,70 @@
|
||||||
|
|
||||||
@test "checking system: freshclam cron is enabled" {
|
@test "checking system: freshclam cron is enabled" {
|
||||||
run docker exec mail bash -c "crontab -l | grep '/usr/bin/freshclam'"
|
run docker exec mail bash -c "crontab -l | grep '/usr/bin/freshclam'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking amavis: virusmail wiper cron exists" {
|
@test "checking amavis: virusmail wiper cron exists" {
|
||||||
run docker exec mail bash -c "crontab -l | grep '/var/lib/amavis/virusmails/'"
|
run docker exec mail bash -c "crontab -l | grep '/var/lib/amavis/virusmails/'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking amavis: VIRUSMAILS_DELETE_DELAY override works as expected" {
|
@test "checking amavis: VIRUSMAILS_DELETE_DELAY override works as expected" {
|
||||||
run docker run -ti --rm -e VIRUSMAILS_DELETE_DELAY=2 `docker inspect --format '{{ .Config.Image }}' mail` /bin/bash -c 'echo $VIRUSMAILS_DELETE_DELAY | grep 2'
|
run docker run -ti --rm -e VIRUSMAILS_DELETE_DELAY=2 `docker inspect --format '{{ .Config.Image }}' mail` /bin/bash -c 'echo $VIRUSMAILS_DELETE_DELAY | grep 2'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking amavis: old virusmail is wipped by cron" {
|
@test "checking amavis: old virusmail is wipped by cron" {
|
||||||
docker exec mail bash -c 'touch -d "`date --date=2000-01-01`" /var/lib/amavis/virusmails/should-be-deleted'
|
docker exec mail bash -c 'touch -d "`date --date=2000-01-01`" /var/lib/amavis/virusmails/should-be-deleted'
|
||||||
run docker exec -ti mail bash -c 'find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete'
|
run docker exec -ti mail bash -c 'find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail bash -c 'ls -la /var/lib/amavis/virusmails/ | grep should-be-deleted'
|
run docker exec mail bash -c 'ls -la /var/lib/amavis/virusmails/ | grep should-be-deleted'
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking amavis: recent virusmail is not wipped by cron" {
|
@test "checking amavis: recent virusmail is not wipped by cron" {
|
||||||
docker exec mail bash -c 'touch -d "`date`" /var/lib/amavis/virusmails/should-not-be-deleted'
|
docker exec mail bash -c 'touch -d "`date`" /var/lib/amavis/virusmails/should-not-be-deleted'
|
||||||
run docker exec -ti mail bash -c 'find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete'
|
run docker exec -ti mail bash -c 'find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail bash -c 'ls -la /var/lib/amavis/virusmails/ | grep should-not-be-deleted'
|
run docker exec mail bash -c 'ls -la /var/lib/amavis/virusmails/ | grep should-not-be-deleted'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking system: /var/log/mail/mail.log is error free" {
|
@test "checking system: /var/log/mail/mail.log is error free" {
|
||||||
run docker exec mail grep 'non-null host address bits in' /var/log/mail/mail.log
|
run docker exec mail grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep 'mail system configuration error' /var/log/mail/mail.log
|
run docker exec mail grep 'mail system configuration error' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep ': error:' /var/log/mail/mail.log
|
run docker exec mail grep ': error:' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep -i 'is not writable' /var/log/mail/mail.log
|
run docker exec mail grep -i 'is not writable' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep -i 'permission denied' /var/log/mail/mail.log
|
run docker exec mail grep -i 'permission denied' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep -i '(!)connect' /var/log/mail/mail.log
|
run docker exec mail grep -i '(!)connect' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
run docker exec mail grep 'non-null host address bits in' /var/log/mail/mail.log
|
run docker exec mail grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking system: /var/log/auth.log is error free" {
|
@test "checking system: /var/log/auth.log is error free" {
|
||||||
run docker exec mail grep 'Unable to open env file: /etc/default/locale' /var/log/auth.log
|
run docker exec mail grep 'Unable to open env file: /etc/default/locale' /var/log/auth.log
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking system: sets the server fqdn" {
|
@test "checking system: sets the server fqdn" {
|
||||||
run docker exec mail hostname
|
run docker exec mail hostname
|
||||||
[ "$status" -eq 0 ]
|
assert_output "mail.my-domain.com"
|
||||||
[ "$output" = "mail.my-domain.com" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking system: sets the server domain name in /etc/mailname" {
|
@test "checking system: sets the server domain name in /etc/mailname" {
|
||||||
run docker exec mail cat /etc/mailname
|
run docker exec mail cat /etc/mailname
|
||||||
[ "$status" -eq 0 ]
|
assert_output "my-domain.com"
|
||||||
[ "$output" = "my-domain.com" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking system: postfix should not log to syslog" {
|
@test "checking system: postfix should not log to syslog" {
|
||||||
run docker exec mail grep 'postfix' /var/log/syslog
|
run docker exec mail grep 'postfix' /var/log/syslog
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -767,8 +737,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/.INBOX.spam/new | wc -l"
|
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/.INBOX.spam/new | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking manage sieve: server is ready when ENABLE_MANAGESIEVE has been set" {
|
@test "checking manage sieve: server is ready when ENABLE_MANAGESIEVE has been set" {
|
||||||
|
@ -776,7 +745,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/bash -c "nc -z 0.0.0.0 4190"
|
run docker exec mail /bin/bash -c "nc -z 0.0.0.0 4190"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking manage sieve: disabled per default" {
|
@test "checking manage sieve: disabled per default" {
|
||||||
|
@ -795,7 +764,7 @@
|
||||||
docker exec mail /bin/sh -c "addmailuser user3@domain.tld mypassword"
|
docker exec mail /bin/sh -c "addmailuser user3@domain.tld mypassword"
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
|
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ ! -z "$output" ]
|
[ ! -z "$output" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,7 +772,7 @@
|
||||||
docker exec mail /bin/sh -c "delmailuser user3@domain.tld"
|
docker exec mail /bin/sh -c "delmailuser user3@domain.tld"
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
|
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
[ -z "$output" ]
|
[ -z "$output" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,21 +793,20 @@
|
||||||
|
|
||||||
docker exec mail /bin/sh -c "delmailuser user3@domain.tld"
|
docker exec mail /bin/sh -c "delmailuser user3@domain.tld"
|
||||||
|
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@test "checking accounts: listmailuser" {
|
@test "checking accounts: listmailuser" {
|
||||||
run docker exec mail /bin/sh -c "listmailuser | head -n 1"
|
run docker exec mail /bin/sh -c "listmailuser | head -n 1"
|
||||||
[ "$status" -eq 0 ]
|
assert_output "user1@localhost.localdomain"
|
||||||
[ "$output" = user1@localhost.localdomain ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking accounts: no error is generated when deleting a user if /tmp/docker-mailserver/postfix-accounts.cf is missing" {
|
@test "checking accounts: no error is generated when deleting a user if /tmp/docker-mailserver/postfix-accounts.cf is missing" {
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'delmailuser user3@domain.tld'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'delmailuser user3@domain.tld'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ -z "$output" ]
|
[ -z "$output" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,7 +817,7 @@
|
||||||
run docker run --rm \
|
run docker run --rm \
|
||||||
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \
|
||||||
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf'
|
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf'
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ ! -z "$output" ]
|
[ ! -z "$output" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,21 +827,21 @@
|
||||||
|
|
||||||
@test "checking PERMIT_DOCKER: can get container ip" {
|
@test "checking PERMIT_DOCKER: can get container ip" {
|
||||||
run docker exec mail /bin/sh -c "ip addr show eth0 | grep 'inet ' | sed 's/[^0-9\.\/]*//g' | cut -d '/' -f 1 | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'"
|
run docker exec mail /bin/sh -c "ip addr show eth0 | grep 'inet ' | sed 's/[^0-9\.\/]*//g' | cut -d '/' -f 1 | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking PERMIT_DOCKER: opendmarc/opendkim config" {
|
@test "checking PERMIT_DOCKER: opendmarc/opendkim config" {
|
||||||
run docker exec mail /bin/sh -c "cat /etc/opendmarc/ignore.hosts | grep '172.16.0.0/12'"
|
run docker exec mail /bin/sh -c "cat /etc/opendmarc/ignore.hosts | grep '172.16.0.0/12'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "cat /etc/opendkim/TrustedHosts | grep '172.16.0.0/12'"
|
run docker exec mail /bin/sh -c "cat /etc/opendkim/TrustedHosts | grep '172.16.0.0/12'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking PERMIT_DOCKER: my network value" {
|
@test "checking PERMIT_DOCKER: my network value" {
|
||||||
run docker exec mail /bin/sh -c "postconf | grep '^mynetworks =' | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.0\.0/16'"
|
run docker exec mail /bin/sh -c "postconf | grep '^mynetworks =' | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.0\.0/16'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run docker exec mail /bin/sh -c "postconf | grep '^mynetworks =' | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/32'"
|
run docker exec mail /bin/sh -c "postconf | grep '^mynetworks =' | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/32'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -882,8 +850,7 @@
|
||||||
|
|
||||||
@test "checking amavis: config overrides" {
|
@test "checking amavis: config overrides" {
|
||||||
run docker exec mail /bin/sh -c "grep 'Test Verification' /etc/amavis/conf.d/50-user | wc -l"
|
run docker exec mail /bin/sh -c "grep 'Test Verification' /etc/amavis/conf.d/50-user | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -893,25 +860,25 @@
|
||||||
# CLI interface
|
# CLI interface
|
||||||
@test "checking setup.sh: Without arguments: status 1, show help text" {
|
@test "checking setup.sh: Without arguments: status 1, show help text" {
|
||||||
run ./setup.sh
|
run ./setup.sh
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
[ "${lines[0]}" = "Usage: ./setup.sh [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]" ]
|
[ "${lines[0]}" = "Usage: ./setup.sh [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]" ]
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: Wrong arguments" {
|
@test "checking setup.sh: Wrong arguments" {
|
||||||
run ./setup.sh lol troll
|
run ./setup.sh lol troll
|
||||||
[ "$status" -eq 1 ]
|
refute
|
||||||
[ "${lines[0]}" = "Usage: ./setup.sh [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]" ]
|
[ "${lines[0]}" = "Usage: ./setup.sh [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# email
|
# email
|
||||||
@test "checking setup.sh: setup.sh email add " {
|
@test "checking setup.sh: setup.sh email add " {
|
||||||
run ./setup.sh -c mail email add lorem@impsum.org dolorsit
|
run ./setup.sh -c mail email add lorem@impsum.org dolorsit
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $1}')
|
value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $1}')
|
||||||
[ "$value" = "lorem@impsum.org" ]
|
[ "$value" = "lorem@impsum.org" ]
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: setup.sh email list" {
|
@test "checking setup.sh: setup.sh email list" {
|
||||||
run ./setup.sh -c mail email list
|
run ./setup.sh -c mail email list
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: setup.sh email update" {
|
@test "checking setup.sh: setup.sh email update" {
|
||||||
initialpass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}')
|
initialpass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}')
|
||||||
|
@ -922,11 +889,11 @@
|
||||||
else
|
else
|
||||||
status="1"
|
status="1"
|
||||||
fi
|
fi
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: setup.sh email del" {
|
@test "checking setup.sh: setup.sh email del" {
|
||||||
run ./setup.sh -c mail email del lorem@impsum.org
|
run ./setup.sh -c mail email del lorem@impsum.org
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
run value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org)
|
run value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org)
|
||||||
[ -z "$value" ]
|
[ -z "$value" ]
|
||||||
}
|
}
|
||||||
|
@ -934,12 +901,12 @@
|
||||||
# config
|
# config
|
||||||
@test "checking setup.sh: setup.sh config dkim" {
|
@test "checking setup.sh: setup.sh config dkim" {
|
||||||
run ./setup.sh -c mail config dkim
|
run ./setup.sh -c mail config dkim
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
# TODO: To create a test generate-ssl-certificate must be non interactive
|
# TODO: To create a test generate-ssl-certificate must be non interactive
|
||||||
#@test "checking setup.sh: setup.sh config ssl" {
|
#@test "checking setup.sh: setup.sh config ssl" {
|
||||||
# run ./setup.sh -c mail_ssl config ssl
|
# run ./setup.sh -c mail_ssl config ssl
|
||||||
# [ "$status" -eq 0 ]
|
# assert
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
|
@ -951,13 +918,13 @@
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: setup.sh debug inspect" {
|
@test "checking setup.sh: setup.sh debug inspect" {
|
||||||
run ./setup.sh -c mail debug inspect
|
run ./setup.sh -c mail debug inspect
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
[ "${lines[0]}" = "Image: tvial/docker-mailserver:testing" ]
|
[ "${lines[0]}" = "Image: tvial/docker-mailserver:testing" ]
|
||||||
[ "${lines[1]}" = "Container: mail" ]
|
[ "${lines[1]}" = "Container: mail" ]
|
||||||
}
|
}
|
||||||
@test "checking setup.sh: setup.sh debug login ls" {
|
@test "checking setup.sh: setup.sh debug login ls" {
|
||||||
run ./setup.sh -c mail debug login ls
|
run ./setup.sh -c mail debug login ls
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -969,15 +936,15 @@
|
||||||
if [ $ENABLE_LDAP -eq 0 ]; then
|
if [ $ENABLE_LDAP -eq 0 ]; then
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run docker exec mail /bin/sh -c "postmap -q some.user@localhost.localdomain ldap:/etc/postfix/ldap-users.cf"
|
run docker exec mail /bin/sh -c "postmap -q some.user@localhost.localdomain ldap:/etc/postfix/ldap-users.cf"
|
||||||
[ "$status" -eq 0 ]
|
assert_output "some.user@localhost.localdomain"
|
||||||
[ "$output" = "some.user@localhost.localdomain" ]
|
|
||||||
run docker exec mail /bin/sh -c "postmap -q postmaster@localhost.localdomain ldap:/etc/postfix/ldap-aliases.cf"
|
run docker exec mail /bin/sh -c "postmap -q postmaster@localhost.localdomain ldap:/etc/postfix/ldap-aliases.cf"
|
||||||
[ "$status" -eq 0 ]
|
assert_output "some.user@localhost.localdomain"
|
||||||
[ "$output" = "some.user@localhost.localdomain" ]
|
|
||||||
run docker exec mail /bin/sh -c "postmap -q employees@localhost.localdomain ldap:/etc/postfix/ldap-groups.cf"
|
run docker exec mail /bin/sh -c "postmap -q employees@localhost.localdomain ldap:/etc/postfix/ldap-groups.cf"
|
||||||
[ "$status" -eq 0 ]
|
assert_output "some.user@localhost.localdomain"
|
||||||
[ "$output" = "some.user@localhost.localdomain" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# dovecot
|
# dovecot
|
||||||
|
@ -986,7 +953,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-ldap-auth.txt"
|
run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-ldap-auth.txt"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking dovecot: mail delivery works" {
|
@test "checking dovecot: mail delivery works" {
|
||||||
|
@ -996,8 +963,7 @@
|
||||||
run docker exec mail /bin/sh -c "sendmail -f user@external.tld some.user@localhost.localdomain < /tmp/docker-mailserver-test/email-templates/test-email.txt"
|
run docker exec mail /bin/sh -c "sendmail -f user@external.tld some.user@localhost.localdomain < /tmp/docker-mailserver-test/email-templates/test-email.txt"
|
||||||
sleep 10
|
sleep 10
|
||||||
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/some.user/new | wc -l"
|
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/some.user/new | wc -l"
|
||||||
[ "$status" -eq 0 ]
|
assert_output 1
|
||||||
[ "$output" -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# saslauthd
|
# saslauthd
|
||||||
|
@ -1006,7 +972,7 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail bash -c "testsaslauthd -u some.user -p secret"
|
run docker exec mail bash -c "testsaslauthd -u some.user -p secret"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking saslauthd: ldap smtp authentication" {
|
@test "checking saslauthd: ldap smtp authentication" {
|
||||||
|
@ -1014,5 +980,5 @@
|
||||||
skip
|
skip
|
||||||
fi
|
fi
|
||||||
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/sasl-ldap-smtp-auth.txt | grep 'Authentication successful'"
|
run docker exec mail /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/sasl-ldap-smtp-auth.txt | grep 'Authentication successful'"
|
||||||
[ "$status" -eq 0 ]
|
assert
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue