]>
diplodocus.org Git - nmh/blob - test/post/test-post-aliases
2 ######################################################
4 # Test aliases all the way through post
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname "$0"`/..
/..
12 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
15 .
"${srcdir}/test/post/test-post-common.sh"
17 # Note that the last address in the blind list does not end with a
19 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
20 blind_list: Blind List: one, two, three
21 named.list; one@example.com, two@example.com
24 three: three@example.com
25 four: Mister Four <four@example.com>
28 #### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
29 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
30 cp "${MHMTSCONF}" "$mts_fakesendmail"
31 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
32 MHMTSCONF
="$mts_fakesendmail"
34 # $1: -mts switch selection
38 if [ "$1" = 'sendmail/smtp' ]; then
39 run_prog send
-draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail
/smtp
41 # fakesendmail drops the message and any cc's into this mbox.
42 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
43 inc
-silent -file "$mbox"
46 # It's hard to calculate the exact Date: header post is going to
47 # use, so we'll just use sed to remove the actual date so we can easily
48 # compare it against our "correct" output.
49 sed -e 's/^Date:.*/Date:/' "`mhpath cur`" >"${testname}.actual"
51 check
"${testname}.actual" "$2"
53 if [ "`mhpath cur`" != "`mhpath last`" ]; then
54 folder next
>/dev
/null
55 arith_eval
$n + 1; n
=$arith_val
58 elif [ "$1" = 'sendmail/pipe' ]; then
60 run_prog send
-draft -alias "${MH_TEST_DIR}/Mail/aliases" \
61 -mts sendmail
/pipe
>"${testname}.actual" 2>&1
63 printf '%s: sendmail/pipe should have failed but didn'"'"'t\n' "$0"
66 check
"${testname}.actual" "$2"
70 printf '%s: invalid -mts switch selection\n' "$0"
77 start_test
"blind list"
78 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
79 From: Mr Nobody <nobody@example.com>
81 Subject: blind list test
83 This is test of a blind list.
85 cp -p "${MH_TEST_DIR}/Mail/draft" "${MH_TEST_DIR}/Mail/draft2"
87 cat >"${testname}.expected" <<EOF
88 From: Mr Nobody <nobody@example.com>
90 Subject: blind list test
92 Content-Type: text/plain; charset="us-ascii"
95 This is test of a blind list.
98 test_alias sendmail
/smtp
"${testname}.expected"
100 # Make sure the addresses were expanded correctly.
101 mv "${MH_TEST_DIR}/Mail/draft2" "${MH_TEST_DIR}/Mail/draft"
103 cat > "${testname}.expected" <<EOF
104 EHLO nosuchhost.example.com
105 MAIL FROM:<nobody@example.com>
106 RCPT TO:<one@example.com>
107 RCPT TO:<two@example.com>
108 RCPT TO:<three@example.com>
110 From: Mr Nobody <nobody@example.com>
112 Subject: blind list test
114 Content-Type: text/plain; charset="us-ascii"
117 This is test of a blind list.
122 test_post
"${testname}.actual" "${testname}.expected" \
123 "-alias ${MH_TEST_DIR}/Mail/aliases"
125 # check named list (alias followed by ;)
126 start_test
"named list (alias followed by ;)"
127 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
128 From: Mr Nobody <nobody@example.com>
130 Subject: named list test
132 This is test of a named list.
135 cat >"${testname}.expected" <<EOF
136 From: Mr Nobody <nobody@example.com>
137 To: "named.list" <one@example.com>, "named.list" <two@example.com>
138 Subject: named list test
140 Content-Type: text/plain; charset="us-ascii"
143 This is test of a named list.
146 test_alias sendmail
/smtp
"${testname}.expected"
148 # check blind list with -mts sendmail/pipe, which should fail
149 start_test
"blind list with -mts sendmail/pipe, which should fail"
150 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
151 From: Mr Nobody <nobody@example.com>
153 Subject: blind list test
155 This is test of a blind list.
158 cat >"${testname}.expected" <<EOF
159 post: blind lists not compatible with sendmail/pipe
160 send: message not delivered to anyone
163 test_alias sendmail
/pipe
"${testname}.expected"
165 # check that alias expansion happens in the From: line when doing a bcc
166 start_test
"that alias expansion happens in the From: line when doing a bcc"
167 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
171 Subject: from bcc expansion test
173 This is test of from line expansion for a bcc.
176 cat >"${testname}.expected" <<EOF
177 EHLO nosuchhost.example.com
178 MAIL FROM:<four@example.com>
179 RCPT TO:<one@example.com>
180 RCPT TO:<two@example.com>
182 MAIL FROM:<four@example.com>
183 RCPT TO:<one@example.com>
185 From: Mister Four <four@example.com>
187 Subject: from bcc expansion test
189 Content-Type: text/plain; charset="us-ascii"
192 This is test of from line expansion for a bcc.
195 MAIL FROM:<four@example.com>
196 RCPT TO:<two@example.com>
198 From: Mister Four <four@example.com>
200 Subject: from bcc expansion test
203 ------- Blind-Carbon-Copy
205 From: Mister Four <four@example.com>
207 Subject: from bcc expansion test
209 Content-Type: text/plain; charset="us-ascii"
212 This is test of from line expansion for a bcc.
214 ------- End of Blind-Carbon-Copy
219 test_post
"${testname}.actual" "${testname}.expected" \
220 "-alias ${MH_TEST_DIR}/Mail/aliases"