Testfixes & more (#942)

* fixed useless updatetest, made updatemailuser and addmailuser setup.sh compliant.
* changed documentation
This commit is contained in:
17Halbe 2018-04-08 16:12:41 +02:00 committed by Johan Smits
parent a564cca0e5
commit 59ce9d03f0
4 changed files with 19 additions and 14 deletions

View file

@ -222,6 +222,8 @@ run:
generate-accounts-after-run: generate-accounts-after-run:
docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
docker exec mail addmailuser pass@localhost.localdomain 'may be \a `p^a.*ssword'
sleep 10 sleep 10
fixtures: fixtures:

View file

@ -3,7 +3,8 @@
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf} DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
USER="$1" USER="$1"
PASSWD="$2" shift
PASSWD="$@"
usage() { usage() {
echo "Usage: addmailuser <user@domain> [<password>]" echo "Usage: addmailuser <user@domain> [<password>]"

View file

@ -3,7 +3,8 @@
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf} DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
USER="$1" USER="$1"
PASSWD="$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$2")" shift
PASSWD="$@"
usage() { usage() {
echo "Usage: updatemailuser <user@domain.tld> [password]" echo "Usage: updatemailuser <user@domain.tld> [password]"
@ -20,6 +21,13 @@ escape() {
[ -z "$USER" ] && { usage; errex "no username specified"; } [ -z "$USER" ] && { usage; errex "no username specified"; }
if [ -z "$PASSWD" ]; then
read -s -p "Enter Password: " PASSWD
echo
[ -z "$PASSWD" ] && errex "Password must not be empty"
fi
HASH="$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASSWD")"
grep -qi "^$(escape "$USER")|" $DATABASE 2>/dev/null || grep -qi "^$(escape "$USER")|" $DATABASE 2>/dev/null ||
errex "User \"$USER\" does not exist" errex "User \"$USER\" does not exist"
sed -i "s ^"$USER"|.* "$USER"|"$PASSWD" " $DATABASE
sed -i "s ^"$USER"|.* "$USER"|"$HASH" " $DATABASE

View file

@ -1198,12 +1198,6 @@ load 'test_helper/bats-assert/load'
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" ]
# don't know why, but the test suite needs to delete the (non existant) user prior succeeding in adding him again.
# when executed directly against the container this workaround is not neccessary.
run docker exec mail delmailuser -y pass@localhorst.localdomain
assert_success
docker exec mail addmailuser pass@localhost.localdomain 'may be \a `p^a.*ssword'
sleep 30
docker exec mail doveadm auth test -x service=smtp pass@localhost.localdomain 'may be \a `p^a.*ssword' | grep 'auth succeeded' docker exec mail doveadm auth test -x service=smtp pass@localhost.localdomain 'may be \a `p^a.*ssword' | grep 'auth succeeded'
assert_success assert_success
} }
@ -1215,13 +1209,13 @@ load 'test_helper/bats-assert/load'
@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}')
run ./setup.sh -c mail email update lorem@impsum.org consectetur run ./setup.sh email update lorem@impsum.org my password
sleep 10
updatepass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}') updatepass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}')
[ "$initialpass" != "$changepass" ] [ "$initialpass" != "$updatepass" ]
assert_success
docker exec mail /bin/sh -c "updatemailuser pass@localhost.localdomain 'my other password'" docker exec mail doveadm pw -t "$updatepass" -p 'my password' | grep 'verified'
sleep 30
docker exec mail /bin/sh -c "doveadm auth test -x service=smtp pass@localhost.localdomain 'my other password' | grep 'auth succeeded'"
assert_success assert_success
} }