]>
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
151 check
"$draft" "$expected"
154 # Make sure we fail if we run into a MIME-Version header
158 To: Mr Test <mrtest@example.com>
161 Subject: Test of an already-MIMEified message
163 Content-Type: text/plain; charset="us-ascii"
165 This is a preformatted MIME content test.
169 run_test
'eval mhbuild "$draft"' "mhbuild: draft shouldn't contain MIME-Version: field"
173 # Run it again using -auto
176 run_prog mhbuild
-auto "$draft"
178 cat > "$expected" <<EOF
179 To: Mr Test <mrtest@example.com>
182 Subject: Test of an already-MIMEified message
184 Content-Type: text/plain; charset="us-ascii"
186 This is a preformatted MIME content test.
189 check
"$draft" "$expected"
192 # Make sure -dist does nothing but encode headers
196 To: Señor Test <mrtest@example.com>
199 Subject: An empty dist test
202 run_prog mhbuild
-dist "$draft"
204 cat > "$expected" <<EOF
205 To: =?UTF-8?Q?Se=C3=B1or_Test?= <mrtest@example.com>
208 Subject: An empty dist test
211 check
"$draft" "$expected"
214 # Two parts, one attachment; make sure mixing of multiparts at different
215 # levels works. This also tests Attach: instead of Nmh-Attach:.
219 To: Mr Test <mrtest@example.com>
222 Subject: A more complete multipart test
223 Attach: ${srcdir}/test/mhbuild/tiny.jpg
231 This is some HTML tëxt.
237 run_prog mhbuild
"$draft"
239 cat > "$expected" <<EOF
240 To: Mr Test <mrtest@example.com>
243 Subject: A more complete multipart test
245 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
246 Content-Transfer-Encoding: 8bit
248 ------- =_aaaaaaaaaa0
249 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
250 Content-Transfer-Encoding: 8bit
252 ------- =_aaaaaaaaaa1
253 Content-Type: text/plain; charset="UTF-8"
254 Content-Transfer-Encoding: 8bit
258 ------- =_aaaaaaaaaa1
259 Content-Type: text/html; charset="UTF-8"
260 Content-Transfer-Encoding: 8bit
264 This is some HTML tëxt.
268 ------- =_aaaaaaaaaa1--
270 ------- =_aaaaaaaaaa0
271 Content-Type: image/jpeg; name="tiny.jpg"
272 Content-Description: tiny.jpg
273 Content-Disposition: attachment; filename="tiny.jpg"
274 Content-Transfer-Encoding: base64
278 ------- =_aaaaaaaaaa0--
281 check
"$draft" "$expected"
284 # One attachment, text/plain containing some binary characters,
289 To: Mr Test <mrtest@example.com>
292 Subject: Testing some binary chars
295 #text/plain; name="somebinary" [ - ] {attachment} ${srcdir}/test/mhbuild/somebinary
298 run_prog mhbuild
"$draft"
300 cat > "$expected" <<EOF
301 To: Mr Test <mrtest@example.com>
304 Subject: Testing some binary chars
306 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
307 Content-Transfer-Encoding: 8bit
309 ------- =_aaaaaaaaaa0
310 Content-Type: text/plain; charset="UTF-8"
311 Content-Transfer-Encoding: 8bit
315 ------- =_aaaaaaaaaa0
316 Content-Type: text/plain; name="somebinary"; charset="us-ascii"
317 Content-Description: -
318 Content-Disposition: attachment; filename="somebinary"
319 Content-Transfer-Encoding: quoted-printable
322 =46rom here on, this is only =
324 a test, though it contains =13ome
327 ------- =_aaaaaaaaaa0--
330 check
"$draft" "$expected"
332 # check that blank line is inserted between header and content
334 cat > "$MH_TEST_DIR/Mail/oneline" <<EOF
335 There needs to be a blank line before this content line.
339 To: Mr Test <mrtest@example.com>
342 Subject: test blank line between header and content
344 #text/plain {inline} $MH_TEST_DIR/Mail/oneline
345 #application/octet-stream {inline} $MH_TEST_DIR/Mail/oneline
348 run_prog mhbuild
"$draft"
350 cat > "$expected" <<EOF
351 To: Mr Test <mrtest@example.com>
354 Subject: test blank line between header and content
356 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
358 ------- =_aaaaaaaaaa0
359 Content-Type: text/plain; charset="us-ascii"
360 Content-Disposition: inline; filename="oneline"
362 There needs to be a blank line before this content line.
364 ------- =_aaaaaaaaaa0
365 Content-Type: application/octet-stream
366 Content-Disposition: inline; filename="oneline"
368 There needs to be a blank line before this content line.
370 ------- =_aaaaaaaaaa0--
373 check
"$draft" "$expected"
376 [ ${failed:=0} -eq 0 ] && rm -f ${backup}