mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Testfixes & more (#942)
* fixed useless updatetest, made updatemailuser and addmailuser setup.sh compliant. * changed documentation
This commit is contained in:
parent
a564cca0e5
commit
59ce9d03f0
2
Makefile
2
Makefile
|
@ -222,6 +222,8 @@ 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 exec mail addmailuser pass@localhost.localdomain 'may be \a `p^a.*ssword'
|
||||
|
||||
sleep 10
|
||||
|
||||
fixtures:
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
||||
|
||||
USER="$1"
|
||||
PASSWD="$2"
|
||||
shift
|
||||
PASSWD="$@"
|
||||
|
||||
usage() {
|
||||
echo "Usage: addmailuser <user@domain> [<password>]"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
||||
|
||||
USER="$1"
|
||||
PASSWD="$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$2")"
|
||||
shift
|
||||
PASSWD="$@"
|
||||
|
||||
usage() {
|
||||
echo "Usage: updatemailuser <user@domain.tld> [password]"
|
||||
|
@ -20,6 +21,13 @@ escape() {
|
|||
|
||||
[ -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 ||
|
||||
errex "User \"$USER\" does not exist"
|
||||
sed -i "s ^"$USER"|.* "$USER"|"$PASSWD" " $DATABASE
|
||||
|
||||
sed -i "s ^"$USER"|.* "$USER"|"$HASH" " $DATABASE
|
||||
|
|
|
@ -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" = "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'
|
||||
assert_success
|
||||
}
|
||||
|
@ -1215,13 +1209,13 @@ load 'test_helper/bats-assert/load'
|
|||
|
||||
@test "checking setup.sh: setup.sh email update" {
|
||||
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}')
|
||||
[ "$initialpass" != "$changepass" ]
|
||||
[ "$initialpass" != "$updatepass" ]
|
||||
assert_success
|
||||
|
||||
docker exec mail /bin/sh -c "updatemailuser pass@localhost.localdomain 'my other password'"
|
||||
sleep 30
|
||||
docker exec mail /bin/sh -c "doveadm auth test -x service=smtp pass@localhost.localdomain 'my other password' | grep 'auth succeeded'"
|
||||
docker exec mail doveadm pw -t "$updatepass" -p 'my password' | grep 'verified'
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue