]>
diplodocus.org Git - nmh/blob - test/mhbuild/test-attach
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 # along with message text.
58 To: Mr Test <mrtest@example.com>
61 Nmh-Attach: ${srcdir}/test/mhbuild/tiny.jpg
62 Nmh-Attach: ${srcdir}/test/mhbuild/nulls
67 run_prog mhbuild
"$draft"
69 cat > "$expected" <<EOF
70 To: Mr Test <mrtest@example.com>
74 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
77 Content-Type: text/plain; charset="us-ascii"
82 Content-Type: image/jpeg; name="tiny.jpg"
83 Content-Description: tiny.jpg
84 Content-Disposition: attachment; filename="tiny.jpg"
85 Content-Transfer-Encoding: base64
90 Content-Type: application/octet-stream; name="nulls"
91 Content-Description: nulls
92 Content-Disposition: attachment; filename="nulls"
93 Content-Transfer-Encoding: base64
97 ------- =_aaaaaaaaaa0--
100 check
"$draft" "$expected"
103 # An empty Attach header
107 To: Mr Test <mrtest@example.com>
112 This is a test of an empty attach header.
115 run_prog mhbuild
"$draft"
117 cat > "$expected" <<EOF
118 To: Mr Test <mrtest@example.com>
122 Content-Type: text/plain; charset="us-ascii"
124 This is a test of an empty attach header.
127 check
"$draft" "$expected"
130 # Check a completely empty message
134 To: Mr Test <mrtest@example.com>
137 Subject: Test of an empty body
140 run_prog mhbuild
"$draft"
142 cat > "$expected" <<EOF
143 To: Mr Test <mrtest@example.com>
146 Subject: Test of an empty body
148 Content-Type: text/plain
152 # Check an md5'd attachment
156 To: Mr Test <mrtest@example.com>
159 Subject: Test of digested part
161 #text/plain; name="textplain" [ - ] ${srcdir}/test/mhbuild/textplain
165 mhbuild
-check "$draft"
167 cat > "$expected" <<EOF
168 To: Mr Test <mrtest@example.com>
171 Subject: Test of digested part
173 Content-Type: text/plain; name="textplain"; charset="us-ascii"
174 Content-Description: -
175 Content-MD5: x3hNJn10cGowZv+ILUkycw==
176 Content-Transfer-Encoding: quoted-printable
178 This is a text/plain part.
181 check
"$draft" "$expected"
184 # Make sure we fail if we run into a MIME-Version header
188 To: Mr Test <mrtest@example.com>
191 Subject: Test of an already-MIMEified message
193 Content-Type: text/plain; charset="us-ascii"
195 This is a preformatted MIME content test.
199 run_test
'eval mhbuild "$draft"' "mhbuild: draft shouldn't contain MIME-Version: field"
203 # Run it again using -auto
206 run_prog mhbuild
-auto "$draft"
208 cat > "$expected" <<EOF
209 To: Mr Test <mrtest@example.com>
212 Subject: Test of an already-MIMEified message
214 Content-Type: text/plain; charset="us-ascii"
216 This is a preformatted MIME content test.
219 check
"$draft" "$expected"
222 # Make sure -dist does nothing but encode headers
226 To: Señor Test <mrtest@example.com>
229 Subject: An empty dist test
232 run_prog mhbuild
-dist "$draft"
234 cat > "$expected" <<EOF
235 To: =?UTF-8?Q?Se=C3=B1or_Test?= <mrtest@example.com>
238 Subject: An empty dist test
241 check
"$draft" "$expected"
244 # Two parts, one attachment; make sure mixing of multiparts at different
245 # levels works. This also tests Attach: instead of Nmh-Attach:.
249 To: Mr Test <mrtest@example.com>
252 Subject: A more complete multipart test
253 Attach: ${srcdir}/test/mhbuild/tiny.jpg
261 This is some HTML tëxt.
267 run_prog mhbuild
"$draft"
269 cat > "$expected" <<EOF
270 To: Mr Test <mrtest@example.com>
273 Subject: A more complete multipart test
275 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
276 Content-Transfer-Encoding: 8bit
278 ------- =_aaaaaaaaaa0
279 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
280 Content-Transfer-Encoding: 8bit
282 ------- =_aaaaaaaaaa1
283 Content-Type: text/plain; charset="UTF-8"
284 Content-Transfer-Encoding: 8bit
288 ------- =_aaaaaaaaaa1
289 Content-Type: text/html; charset="UTF-8"
290 Content-Transfer-Encoding: 8bit
294 This is some HTML tëxt.
298 ------- =_aaaaaaaaaa1--
300 ------- =_aaaaaaaaaa0
301 Content-Type: image/jpeg; name="tiny.jpg"
302 Content-Description: tiny.jpg
303 Content-Disposition: attachment; filename="tiny.jpg"
304 Content-Transfer-Encoding: base64
308 ------- =_aaaaaaaaaa0--
311 check
"$draft" "$expected"
314 # One attachment, text/plain containing some binary characters,
319 To: Mr Test <mrtest@example.com>
322 Subject: Testing some binary chars
325 #text/plain; name="somebinary" [ - ] {attachment} ${srcdir}/test/mhbuild/somebinary
328 run_prog mhbuild
"$draft"
330 cat > "$expected" <<EOF
331 To: Mr Test <mrtest@example.com>
334 Subject: Testing some binary chars
336 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
337 Content-Transfer-Encoding: 8bit
339 ------- =_aaaaaaaaaa0
340 Content-Type: text/plain; charset="UTF-8"
341 Content-Transfer-Encoding: 8bit
345 ------- =_aaaaaaaaaa0
346 Content-Type: text/plain; name="somebinary"; charset="us-ascii"
347 Content-Description: -
348 Content-Disposition: attachment; filename="somebinary"
349 Content-Transfer-Encoding: quoted-printable
352 =46rom here on, this is only =
354 a test, though it contains =13ome
357 ------- =_aaaaaaaaaa0--
360 check
"$draft" "$expected"
362 # check that blank line is inserted between header and content
364 cat > "$MH_TEST_DIR/Mail/oneline" <<EOF
365 There needs to be a blank line before this content line.
369 To: Mr Test <mrtest@example.com>
372 Subject: test blank line between header and content
374 #text/plain {inline} $MH_TEST_DIR/Mail/oneline
375 #application/octet-stream {inline} $MH_TEST_DIR/Mail/oneline
378 run_prog mhbuild
"$draft"
380 cat > "$expected" <<EOF
381 To: Mr Test <mrtest@example.com>
384 Subject: test blank line between header and content
386 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
388 ------- =_aaaaaaaaaa0
389 Content-Type: text/plain; charset="us-ascii"
390 Content-Disposition: inline; filename="oneline"
392 There needs to be a blank line before this content line.
394 ------- =_aaaaaaaaaa0
395 Content-Type: application/octet-stream
396 Content-Disposition: inline; filename="oneline"
398 There needs to be a blank line before this content line.
400 ------- =_aaaaaaaaaa0--
403 check
"$draft" "$expected"
406 [ ${failed:=0} -eq 0 ] && rm -f ${backup}