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"; }
|
[ -z "$EMAIL" ] || [ -z "$RECIPIENT" ] && { usage; errex "No email specifed"; }
|
||||||
[ -s "$DATABASE" ] || exit 0
|
[ -s "$DATABASE" ] || exit 0
|
||||||
|
|
||||||
CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}')
|
#CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}')
|
||||||
|
sed -i -e "/^$EMAIL *$RECIPIENT$/d" \
|
||||||
if [[ $CNT -eq 2 ]]; then
|
-e "/^$EMAIL/s/,$RECIPIENT//g" \
|
||||||
sed -i "/^$EMAIL/d" $DATABASE
|
-e "/^$EMAIL/s/$RECIPIENT,//g" $DATABASE
|
||||||
else
|
|
||||||
sed -i "/^$EMAIL/s/,$RECIPIENT//g" $DATABASE
|
|
||||||
fi
|
|
||||||
|
|
|
@ -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'
|
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
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking setup.sh: setup.sh alias del" {
|
@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
|
./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
|
./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
|
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
|
# config
|
||||||
|
|
Loading…
Reference in New Issue