Implement ./setup.sh email list (#287)

This commit adds a script nammed 'listmailuser'. './setup.sh' uses this
this script for its subcommand './setup.sh email list'. A test have
been added too.
This commit is contained in:
Josef Friedrich 2016-08-29 13:44:36 +02:00 committed by Thomas VIAL
parent 69ee54513e
commit 98e59a7abe
4 changed files with 27 additions and 4 deletions

View File

@ -75,7 +75,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /et
curl -s https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem
# Start-mailserver script
ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/bin/addmailuser target/bin/delmailuser target/start-mailserver.sh /usr/local/bin/
ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/bin/addmailuser target/bin/delmailuser target/bin/listmailuser target/start-mailserver.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/*
EXPOSE 25 587 143 993 110 995 4190

View File

@ -17,7 +17,7 @@ SUBCOMMANDS:
$0 email add <email> <password>
$0 email del <email>
$0 email list (not yet implemented)
$0 email list
config:
@ -52,8 +52,9 @@ case $1 in
_docker delmailuser $@
;;
# list)
# ;;
list)
_docker listmailuser
;;
*)
_usage

16
target/bin/listmailuser Executable file
View File

@ -0,0 +1,16 @@
#! /bin/sh
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
if [ ! -f "$DATABASE" ]; then
echo "The configuration file 'postfix-accounts.cf' doesn't exist. Until now no email addresses have been added."
exit 1
fi
if [ ! -s "$DATABASE" ]; then
echo "No email addresses have been added."
exit 1
fi
cat "$DATABASE" | awk -F '|' '{print $1}'

View File

@ -591,6 +591,12 @@
[ -z "$output" ]
}
@test "checking accounts: listmailuser" {
run docker exec mail /bin/sh -c "listmailuser | head -n 1"
[ "$status" -eq 0 ]
[ "$output" = user1@localhost.localdomain ]
}
@test "checking accounts: no error is generated when deleting a user if /tmp/docker-mailserver/postfix-accounts.cf is missing" {
run docker run --rm \
-v "$(pwd)/test/config/without-accounts/":/tmp/docker-mailserver/ \