| 1 |
#! /bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
dir=$(pwd)/debian/tests |
| 5 |
. $dir/textutils.sh |
| 6 |
|
| 7 |
frame "Test for debian/patches/features/Wrap-long-lines.patch" |
| 8 |
|
| 9 |
echo "============ enable pam_group for cron =====================" |
| 10 |
echo "auth optional pam_group.so" >> /etc/pam.d/cron |
| 11 |
|
| 12 |
echo "================= adding user 'dummy' =====================" |
| 13 |
getent passwd dummy || adduser --disabled-password --gecos "" dummy |
| 14 |
touch /var/mail/dummy && chown dummy /var/mail/dummy |
| 15 |
|
| 16 |
echo "===== group 'plugdev' for user dummy, with group.conf =====" |
| 17 |
grep -q dummy /etc/security/group.conf || echo "*;*;dummy;Al0000-2400;plugdev" >> /etc/security/group.conf |
| 18 |
|
| 19 |
echo "======== create a crontab for user dummy ==================" |
| 20 |
mylocalhost=$(cat /etc/hostname) |
| 21 |
cp $(pwd)/debian/tests/cron-qp.in /tmp/ |
| 22 |
crontab -u dummy - <<EOF |
| 23 |
MAILTO=dummy@$mylocalhost |
| 24 |
MAILFROM=dummy@$mylocalhost |
| 25 |
* * * * * cat /tmp/cron-qp.in |
| 26 |
EOF |
| 27 |
|
| 28 |
echo "====== launch 'cron -N' in order to check it now ==========" |
| 29 |
cron -N |
| 30 |
echo "================== sleep 5 seconds ========================" |
| 31 |
sleep 5 |
| 32 |
echo "========== check e-mails got by user dummy ================" |
| 33 |
echo "type *" | (su - dummy -c mail || echo "something went wrong while launching 'mail' with dummy user, retcode = $?") > e-mails |
| 34 |
|
| 35 |
echo "========== e-mails content: ===============================" |
| 36 |
cat e-mails |
| 37 |
|
| 38 |
frame "the goal of the first test is to check whether environment variables" \ |
| 39 |
"MAILFROM and MAILTO are correctly taken in account" |
| 40 |
|
| 41 |
echo "===========================================================" |
| 42 |
grep "From: dummy@$mylocalhost" e-mails || abort "test failed" |
| 43 |
grep "To: dummy@$mylocalhost" e-mails || abort "test failed" |
| 44 |
|
| 45 |
frame "OK, this is great: MAILFROM and MAILTO variables are honored" |
| 46 |
|
| 47 |
frame "the goal of the next test is to check whether e-mails do contain" \ |
| 48 |
"QP-encoded wrapped long lines as expected." |
| 49 |
|
| 50 |
grep -q "$(cat $(pwd)/debian/tests/cron-qp.out)" e-mails || echo "contents of cron-qp.out were expected but not found" >&2 |
| 51 |
|
| 52 |
frame "OK, this is great: long lines were wrapped." |
| 53 |
|
| 54 |
exit 0 |