mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
fixed delalias, added additional tests (Closes: #909)
This commit is contained in:
parent
2167108ec0
commit
f682dfc15d
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue