1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
#!/bin/sh
######################################################
#
# Test aliases all the way through post
#
######################################################
set -e
if test -z "${MH_OBJ_DIR}"; then
srcdir=`dirname "$0"`/../..
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi
. "${srcdir}/test/post/test-post-common.sh"
# Note that the last address in the blind list does not end with a
# semicolon.
cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
blind_list: Blind List: one, two, three
named.list; one@example.com, two@example.com
one: one@example.com
two: two@example.com
three: three@example.com
four: Mister Four <four@example.com>
EOF
#### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
mts_fakesendmail="${MHMTSCONF}-fakesendmail"
cp "${MHMTSCONF}" "$mts_fakesendmail"
printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
MHMTSCONF="$mts_fakesendmail"
# $1: -mts switch selection
# $2: expected output
test_alias ()
{
if [ "$1" = 'sendmail/smtp' ]; then
run_prog send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/smtp
# fakesendmail drops the message and any cc's into this mbox.
mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
inc -silent -file "$mbox"
rm -f "$mbox"
# It's hard to calculate the exact Date: header post is going to
# use, so we'll just use sed to remove the actual date so we can easily
# compare it against our "correct" output.
sed -e 's/^Date:.*/Date:/' "`mhpath cur`" >"${testname}.actual"
check "${testname}.actual" "$2"
if [ "`mhpath cur`" != "`mhpath last`" ]; then
folder next >/dev/null
arith_eval $n + 1; n=$arith_val
fi
elif [ "$1" = 'sendmail/pipe' ]; then
set +e
run_prog send -draft -alias "${MH_TEST_DIR}/Mail/aliases" \
-mts sendmail/pipe >"${testname}.actual" 2>&1
if [ $? -eq 0 ]; then
printf '%s: sendmail/pipe should have failed but didn'"'"'t\n' "$0"
else
set -e
check "${testname}.actual" "$2"
fi
else
printf '%s: invalid -mts switch selection\n' "$0"
exit 1
fi
}
# check blind list
start_test "blind list"
cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
From: Mr Nobody <nobody@example.com>
To: blind_list
Subject: blind list test
This is test of a blind list.
EOF
cp -p "${MH_TEST_DIR}/Mail/draft" "${MH_TEST_DIR}/Mail/draft2"
cat >"${testname}.expected" <<EOF
From: Mr Nobody <nobody@example.com>
To: Blind List: ;
Subject: blind list test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:
This is test of a blind list.
EOF
test_alias sendmail/smtp "${testname}.expected"
# Make sure the addresses were expanded correctly.
mv "${MH_TEST_DIR}/Mail/draft2" "${MH_TEST_DIR}/Mail/draft"
cat > "${testname}.expected" <<EOF
EHLO nosuchhost.example.com
MAIL FROM:<nobody@example.com>
RCPT TO:<one@example.com>
RCPT TO:<two@example.com>
RCPT TO:<three@example.com>
DATA
From: Mr Nobody <nobody@example.com>
To: Blind List: ;
Subject: blind list test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:
This is test of a blind list.
.
QUIT
EOF
test_post "${testname}.actual" "${testname}.expected" \
"-alias ${MH_TEST_DIR}/Mail/aliases"
# check named list (alias followed by ;)
start_test "named list (alias followed by ;)"
cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
From: Mr Nobody <nobody@example.com>
To: named.list
Subject: named list test
This is test of a named list.
EOF
cat >"${testname}.expected" <<EOF
From: Mr Nobody <nobody@example.com>
To: "named.list" <one@example.com>, "named.list" <two@example.com>
Subject: named list test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:
This is test of a named list.
EOF
test_alias sendmail/smtp "${testname}.expected"
# check blind list with -mts sendmail/pipe, which should fail
start_test "blind list with -mts sendmail/pipe, which should fail"
cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
From: Mr Nobody <nobody@example.com>
To: blind_list
Subject: blind list test
This is test of a blind list.
EOF
cat >"${testname}.expected" <<EOF
post: blind lists not compatible with sendmail/pipe
send: message not delivered to anyone
EOF
test_alias sendmail/pipe "${testname}.expected"
# check that alias expansion happens in the From: line when doing a bcc
start_test "that alias expansion happens in the From: line when doing a bcc"
cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
From: four
To: one
Bcc: two
Subject: from bcc expansion test
This is test of from line expansion for a bcc.
EOF
cat >"${testname}.expected" <<EOF
EHLO nosuchhost.example.com
MAIL FROM:<four@example.com>
RCPT TO:<one@example.com>
RCPT TO:<two@example.com>
RSET
MAIL FROM:<four@example.com>
RCPT TO:<one@example.com>
DATA
From: Mister Four <four@example.com>
To: one@example.com
Subject: from bcc expansion test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:
This is test of from line expansion for a bcc.
.
RSET
MAIL FROM:<four@example.com>
RCPT TO:<two@example.com>
DATA
From: Mister Four <four@example.com>
Date:
Subject: from bcc expansion test
BCC:
------- Blind-Carbon-Copy
From: Mister Four <four@example.com>
To: one@example.com
Subject: from bcc expansion test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:
This is test of from line expansion for a bcc.
------- End of Blind-Carbon-Copy
.
QUIT
EOF
test_post "${testname}.actual" "${testname}.expected" \
"-alias ${MH_TEST_DIR}/Mail/aliases"
finish_test
exit ${failed:-0}
|