Dkim key size - Addon (#871)

* added Tests
This commit is contained in:
Marek Walczak 2018-03-03 09:20:23 +01:00 committed by Johan Smits
parent d9502ab6e7
commit 253c8faef6
3 changed files with 75 additions and 3 deletions

View file

@ -263,9 +263,11 @@ clean:
fi
-sudo rm -rf test/onedir \
test/config/empty \
test/config/keyDefault \
test/config/key2048 \
test/config/key1024 \
test/config/without-accounts \
test/config/without-virtual \
test/config/with-domain \
test/config/dovecot-lmtp/userdb \
test/config/postfix-*-access.cf*

View file

@ -58,7 +58,7 @@ SUBCOMMANDS:
config:
$0 config dkim
$0 config dkim <keysize> (default: 2048)
$0 config ssl
debug:
@ -186,7 +186,7 @@ case $1 in
shift
case $1 in
dkim)
_docker_image generate-dkim-config
_docker_image generate-dkim-config $2
;;
ssl)
_docker_image generate-ssl-certificate

View file

@ -527,6 +527,76 @@ load 'test_helper/bats-assert/load'
assert_output 2
}
# this set of tests is of low quality. It does not test the RSA-Key size properly via openssl or similar
# Instead it tests the file-size (here 511) - which may differ with a different domain names
# This test may be re-used as a global test to provide better test coverage.
@test "checking opendkim: generator creates default keys size" {
# Prepare default key size 2048
rm -rf "$(pwd)/test/config/keyDefault" && mkdir -p "$(pwd)/test/config/keyDefault"
run docker run --rm \
-v "$(pwd)/test/config/keyDefault/":/tmp/docker-mailserver/ \
-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 \
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config | wc -l'
assert_success
assert_output 6
run docker run --rm \
-v "$(pwd)/test/config/keyDefault/opendkim":/etc/opendkim \
`docker inspect --format '{{ .Config.Image }}' mail` \
/bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt'
assert_success
assert_output 511
}
# this set of tests is of low quality. It does not test the RSA-Key size properly via openssl or similar
# Instead it tests the file-size (here 511) - which may differ with a different domain names
# This test may be re-used as a global test to provide better test coverage.
@test "checking opendkim: generator creates key size 2048" {
# Prepare set key size 2048
rm -rf "$(pwd)/test/config/key2048" && mkdir -p "$(pwd)/test/config/key2048"
run docker run --rm \
-v "$(pwd)/test/config/key2048/":/tmp/docker-mailserver/ \
-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 \
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config 2048 | wc -l'
assert_success
assert_output 6
run docker run --rm \
-v "$(pwd)/test/config/key2048/opendkim":/etc/opendkim \
`docker inspect --format '{{ .Config.Image }}' mail` \
/bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt'
assert_success
assert_output 511
}
# this set of tests is of low quality. It does not test the RSA-Key size properly via openssl or similar
# Instead it tests the file-size (here 329) - which may differ with a different domain names
# This test may be re-used as a global test to provide better test coverage.
@test "checking opendkim: generator creates key size 1024" {
# Prepare set key size 1024
rm -rf "$(pwd)/test/config/key1024" && mkdir -p "$(pwd)/test/config/key1024"
run docker run --rm \
-v "$(pwd)/test/config/key1024/":/tmp/docker-mailserver/ \
-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 \
`docker inspect --format '{{ .Config.Image }}' mail` /bin/sh -c 'generate-dkim-config 1024 | wc -l'
assert_success
assert_output 6
run docker run --rm \
-v "$(pwd)/test/config/key1024/opendkim":/etc/opendkim \
`docker inspect --format '{{ .Config.Image }}' mail` \
/bin/sh -c 'stat -c%s /etc/opendkim/keys/localhost.localdomain/mail.txt'
assert_success
assert_output 329
}
@test "checking opendkim: generator creates keys, tables and TrustedHosts" {
rm -rf "$(pwd)/test/config/empty" && mkdir -p "$(pwd)/test/config/empty"
run docker run --rm \