1#!/bin/bash
2
3# This is an extremely simplistic test harness for the vacation functionality.
4# To judge success or failure you (unfortunately) need to tail -f the log file, which sucks a little,
5# but hey - it's better than no tests, right?
6
7# Original author: David Goodwin (hence all the palepurple.co.uk references!)
8# It would be nice if we could get some sort of status back from the vacation.pl script to indicate mail being sent, or not.
9
10
11
12export PGPASSWORD=gingerdog
13export PGUSER=dg
14export PGDATABASE=postfix
15export PGHOST=pgsqlserver
16
17
18echo "DELETE FROM vacation WHERE email = 'david@example.org'" | psql
19
20# First time around, there should be no vacation record for david@example.org, so these should all not cause mail to be sent.
21# some will trip up spam/mailing list protection etc though
22echo
23echo "NONE OF THESE SHOULD RESULT IN MAIL BEING SENT"
24echo
25
26#echo "On: mailing-list.txt:"
27# cat mailing-list.txt | perl ../vacation.pl -t yes -f fw-general-return-20540-david=example.org@lists.zend.com -- david\#example.org@autoreply.example.org
28echo "On: test-email.txt:"
29cat test-email.txt | perl ../vacation.pl -t yes -f david1@example.org -- david\#example.org@autoreply.example.org
30echo "On: spam.txt:"
31cat spam.txt | perl ../vacation.pl -t yes -f mary@ccr.org -- david\#example.org@autoreply.example.org
32echo "On: asterisk-email.txt:"
33cat asterisk-email.txt | perl ../vacation.pl -t yes -f www-data@palepurple.net -- david\#example.org@autoreply.example.org
34# do not reply to facebook
35echo "On: facebook.txt:"
36cat facebook.txt | perl ../vacation.pl -t yes -f notification+meynbxsa@facebookmail.com -- david\#example.org@autoreply.example.org
37# do not send yourself a vacation notice.
38echo "On: mail-myself.txt:"
39cat mail-myself.txt | perl ../vacation.pl -t yes -f david@example.org -- david\#example.org@autoreply.example.org
40# do not send yourself a vacation notice.
41echo "On: teodor-smtp-envelope-headers.txt:"
42cat teodor-smtp-envelope-headers.txt | perl ../vacation.pl -t yes -f david@example.org -- david\#example.org@autoreply.example.org
43
44
45echo "INSERT INTO vacation (email, subject, body, created, active, domain) VALUES ('david@example.org', 'I am on holiday', 'Yeah, that is right', NOW(), true, 'example.org')" | psql
46
47
48echo
49echo "VACATION TURNED ON "
50echo
51echo "Still ignore mailing list"
52cat mailing-list.txt | perl ../vacation.pl -t yes -f fw-general-return-20540-david=example.org@lists.zend.com -- david\#example.org@autoreply.example.org
53echo " * Should send vacation message for this *"
54cat test-email.txt | perl ../vacation.pl -t yes -f david1@example.org -- david\#example.org@autoreply.example.org
55echo " * Spam - no vacation message for this"
56cat spam.txt | perl ../vacation.pl -t yes -f mary@xxccr.org -- david\#example.org@autoreply.example.org
57echo " * OK - should send vacation message for this"
58cat asterisk-email.txt | perl ../vacation.pl -t yes -f www-data@palepurple.net -- david\#example.org@autoreply.example.org
59echo " * Facebook - should not send vacation message for"
60cat facebook.txt | perl ../vacation.pl -t yes -f notification+meynbxsa@facebookmail.com -- david\#example.org@autoreply.example.org
61echo " * Mailing myself - should not send vacation message"
62cat mail-myself.txt | perl ../vacation.pl -t yes -f david@example.org -- david\#example.org@autoreply.example.org
63echo
64