2 ######################################################
4 # Test the use of the Nmh-Attach: header
6 ######################################################
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir
=`dirname "$0"`/..
/..
10 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 .
"$MH_OBJ_DIR/test/common.sh"
17 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
19 draft
="$MH_TEST_DIR/$$.draft"
20 backup
="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
21 expected
="$MH_TEST_DIR/$$.expected"
24 # Test out a simple draft, one part.
28 To: Mr Test <mrtest@example.com>
31 Nmh-Attach: ${srcdir}/test/mhbuild/tiny.jpg
35 run_prog mhbuild
"$draft"
37 cat > "$expected" <<EOF
38 To: Mr Test <mrtest@example.com>
42 Content-Type: image/jpeg; name="tiny.jpg"
43 Content-Description: tiny.jpg
44 Content-Disposition: attachment; filename="tiny.jpg"
45 Content-Transfer-Encoding: base64
50 check
"$draft" "$expected"
53 # Check out more common case, one (or more) attachments
54 start_test
"out more common case, one (or more) attachments"
55 # along with message text.
59 To: Mr Test <mrtest@example.com>
62 Nmh-Attach: ${srcdir}/test/mhbuild/tiny.jpg
63 Nmh-Attach: ${srcdir}/test/mhbuild/nulls
68 run_prog mhbuild
"$draft"
70 cat > "$expected" <<EOF
71 To: Mr Test <mrtest@example.com>
75 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
78 Content-Type: text/plain; charset="us-ascii"
83 Content-Type: image/jpeg; name="tiny.jpg"
84 Content-Description: tiny.jpg
85 Content-Disposition: attachment; filename="tiny.jpg"
86 Content-Transfer-Encoding: base64
91 Content-Type: application/octet-stream; name="nulls"
92 Content-Description: nulls
93 Content-Disposition: attachment; filename="nulls"
94 Content-Transfer-Encoding: base64
98 ------- =_aaaaaaaaaa0--
101 check
"$draft" "$expected"
104 # An empty Attach header
108 To: Mr Test <mrtest@example.com>
113 This is a test of an empty attach header.
116 run_prog mhbuild
"$draft"
118 cat > "$expected" <<EOF
119 To: Mr Test <mrtest@example.com>
123 Content-Type: text/plain; charset="us-ascii"
125 This is a test of an empty attach header.
128 check
"$draft" "$expected"
131 # Check a completely empty message
132 start_test
"a completely empty message"
136 To: Mr Test <mrtest@example.com>
139 Subject: Test of an empty body
142 run_prog mhbuild
"$draft"
144 cat > "$expected" <<EOF
145 To: Mr Test <mrtest@example.com>
148 Subject: Test of an empty body
150 Content-Type: text/plain
153 check
"$draft" "$expected"
156 # Make sure we fail if we run into a MIME-Version header
160 To: Mr Test <mrtest@example.com>
163 Subject: Test of an already-MIMEified message
165 Content-Type: text/plain; charset="us-ascii"
167 This is a preformatted MIME content test.
171 run_test
'eval mhbuild "$draft"' "mhbuild: draft shouldn't contain MIME-Version: field"
175 # Run it again using -auto
178 run_prog mhbuild
-auto "$draft"
180 cat > "$expected" <<EOF
181 To: Mr Test <mrtest@example.com>
184 Subject: Test of an already-MIMEified message
186 Content-Type: text/plain; charset="us-ascii"
188 This is a preformatted MIME content test.
191 check
"$draft" "$expected"
194 # Make sure -dist does nothing but encode headers
198 To: Señor Test <mrtest@example.com>
201 Subject: An empty dist test
204 run_prog mhbuild
-dist "$draft"
206 cat > "$expected" <<EOF
207 To: =?UTF-8?Q?Se=C3=B1or_Test?= <mrtest@example.com>
210 Subject: An empty dist test
213 check
"$draft" "$expected"
216 # Two parts, one attachment; make sure mixing of multiparts at different
217 # levels works. This also tests Attach: instead of Nmh-Attach:.
221 To: Mr Test <mrtest@example.com>
224 Subject: A more complete multipart test
225 Attach: ${srcdir}/test/mhbuild/tiny.jpg
233 This is some HTML tëxt.
239 run_prog mhbuild
"$draft"
241 cat > "$expected" <<EOF
242 To: Mr Test <mrtest@example.com>
245 Subject: A more complete multipart test
247 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
248 Content-Transfer-Encoding: 8bit
250 ------- =_aaaaaaaaaa0
251 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
252 Content-Transfer-Encoding: 8bit
254 ------- =_aaaaaaaaaa1
255 Content-Type: text/plain; charset="UTF-8"
256 Content-Transfer-Encoding: 8bit
260 ------- =_aaaaaaaaaa1
261 Content-Type: text/html; charset="UTF-8"
262 Content-Transfer-Encoding: 8bit
266 This is some HTML tëxt.
270 ------- =_aaaaaaaaaa1--
272 ------- =_aaaaaaaaaa0
273 Content-Type: image/jpeg; name="tiny.jpg"
274 Content-Description: tiny.jpg
275 Content-Disposition: attachment; filename="tiny.jpg"
276 Content-Transfer-Encoding: base64
280 ------- =_aaaaaaaaaa0--
283 check
"$draft" "$expected"
286 # One attachment, text/plain containing some binary characters,
291 To: Mr Test <mrtest@example.com>
294 Subject: Testing some binary chars
297 #text/plain; name="somebinary" [ - ] {attachment} ${srcdir}/test/mhbuild/somebinary
300 run_prog mhbuild
"$draft"
302 cat > "$expected" <<EOF
303 To: Mr Test <mrtest@example.com>
306 Subject: Testing some binary chars
308 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
309 Content-Transfer-Encoding: 8bit
311 ------- =_aaaaaaaaaa0
312 Content-Type: text/plain; charset="UTF-8"
313 Content-Transfer-Encoding: 8bit
317 ------- =_aaaaaaaaaa0
318 Content-Type: text/plain; name="somebinary"; charset="us-ascii"
319 Content-Description: -
320 Content-Disposition: attachment; filename="somebinary"
321 Content-Transfer-Encoding: quoted-printable
324 =46rom here on, this is only =
326 a test, though it contains =13ome
329 ------- =_aaaaaaaaaa0--
332 check
"$draft" "$expected"
334 # check that blank line is inserted between header and content
335 start_test
"that blank line is inserted between header and content"
337 cat > "$MH_TEST_DIR/Mail/oneline" <<EOF
338 There needs to be a blank line before this content line.
342 To: Mr Test <mrtest@example.com>
345 Subject: test blank line between header and content
347 #text/plain {inline} $MH_TEST_DIR/Mail/oneline
348 #application/octet-stream {inline} $MH_TEST_DIR/Mail/oneline
351 run_prog mhbuild
"$draft"
353 cat > "$expected" <<EOF
354 To: Mr Test <mrtest@example.com>
357 Subject: test blank line between header and content
359 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
361 ------- =_aaaaaaaaaa0
362 Content-Type: text/plain; charset="us-ascii"
363 Content-Disposition: inline; filename="oneline"
365 There needs to be a blank line before this content line.
367 ------- =_aaaaaaaaaa0
368 Content-Type: application/octet-stream
369 Content-Disposition: inline; filename="oneline"
371 There needs to be a blank line before this content line.
373 ------- =_aaaaaaaaaa0--
376 check
"$draft" "$expected"
379 [ ${failed:=0} -eq 0 ] && rm -f ${backup}