You've already forked docker-mailserver
mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-09 23:07:35 +02:00
fixed delalias, added additional tests (Closes: #909)
This commit is contained in:
@@ -21,10 +21,7 @@ escape() {
|
||||
[ -z "$EMAIL" ] || [ -z "$RECIPIENT" ] && { usage; errex "No email specifed"; }
|
||||
[ -s "$DATABASE" ] || exit 0
|
||||
|
||||
CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}')
|
||||
|
||||
if [[ $CNT -eq 2 ]]; then
|
||||
sed -i "/^$EMAIL/d" $DATABASE
|
||||
else
|
||||
sed -i "/^$EMAIL/s/,$RECIPIENT//g" $DATABASE
|
||||
fi
|
||||
#CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}')
|
||||
sed -i -e "/^$EMAIL *$RECIPIENT$/d" \
|
||||
-e "/^$EMAIL/s/,$RECIPIENT//g" \
|
||||
-e "/^$EMAIL/s/$RECIPIENT,//g" $DATABASE
|
||||
|
@@ -1243,12 +1243,27 @@ load 'test_helper/bats-assert/load'
|
||||
run /bin/sh -c 'cat ./config/postfix-virtual.cf | grep "test1@example.org test1@forward.com,test2@forward.com" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking setup.sh: setup.sh alias del" {
|
||||
echo 'test1@example.org test1@forward.com, test2@forward.com,' > ./config/postfix-virtual.cf
|
||||
echo -e 'test1@example.org test1@forward.com,test2@forward.com\ntest2@example.org test1@forward.com' > ./config/postfix-virtual.cf
|
||||
|
||||
./setup.sh -c mail alias del test1@example.org test1@forward.com
|
||||
run grep "test1@forward.com" ./config/postfix-virtual.cf
|
||||
assert_output --regexp "^test2@example.org +test1@forward.com$"
|
||||
|
||||
run grep "test2@forward.com" ./config/postfix-virtual.cf
|
||||
assert_output --regexp "^test1@example.org +test2@forward.com$"
|
||||
|
||||
./setup.sh -c mail alias del test1@example.org test2@forward.com
|
||||
run cat ./config/postfix-virtual.cf | wc -l | grep 0
|
||||
run grep "test1@example.org" ./config/postfix-virtual.cf
|
||||
assert_failure
|
||||
|
||||
run grep "test2@example.org" ./config/postfix-virtual.cf
|
||||
assert_success
|
||||
|
||||
./setup.sh -c mail alias del test2@example.org test1@forward.com
|
||||
run grep "test2@example.org" ./config/postfix-virtual.cf
|
||||
assert_failure
|
||||
}
|
||||
|
||||
# config
|
||||
|
Reference in New Issue
Block a user