]>
diplodocus.org Git - nmh/blob - test/mhbuild/test-attach
2 ######################################################
4 # Test the use of the 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
18 LC_ALL
=en_US.UTF
-8; export LC_ALL
20 draft
="$MH_TEST_DIR/$$.draft"
21 backup
="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
22 expected
="$MH_TEST_DIR/$$.expected"
25 # Test out a simple draft, one part.
29 To: Mr Test <mrtest@example.com>
32 Attach: ${srcdir}/test/mhbuild/tiny.jpg
36 run_prog mhbuild
"$draft"
38 cat > "$expected" <<EOF
39 To: Mr Test <mrtest@example.com>
43 Content-Type: image/jpeg; name="tiny.jpg"
44 Content-Description: tiny.jpg
45 Content-Disposition: attachment; filename="tiny.jpg"
46 Content-Transfer-Encoding: base64
51 check
"$draft" "$expected"
54 # Check out more common case, one (or more) attachments
55 # along with message text.
59 To: Mr Test <mrtest@example.com>
62 Attach: ${srcdir}/test/mhbuild/tiny.jpg
63 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
135 To: Mr Test <mrtest@example.com>
138 Subject: Test of an empty body
141 run_prog mhbuild
"$draft"
143 cat > "$expected" <<EOF
144 To: Mr Test <mrtest@example.com>
147 Subject: Test of an empty body
149 Content-Type: text/plain
153 # Check an md5'd attachment
157 To: Mr Test <mrtest@example.com>
160 Subject: Test of digested part
162 #text/plain; name="textplain" [ - ] ${srcdir}/test/mhbuild/textplain
166 mhbuild
-check "$draft"
168 cat > "$expected" <<EOF
169 To: Mr Test <mrtest@example.com>
172 Subject: Test of digested part
174 Content-Type: text/plain; name="textplain"; charset="us-ascii"
175 Content-Description: -
176 Content-MD5: x3hNJn10cGowZv+ILUkycw==
177 Content-Transfer-Encoding: quoted-printable
179 This is a text/plain part.
182 check
"$draft" "$expected"
185 # Make sure we fail if we run into a MIME-Version header
189 To: Mr Test <mrtest@example.com>
192 Subject: Test of an already-MIMEified message
194 Content-Type: text/plain; charset="us-ascii"
196 This is a preformatted MIME content test.
200 run_test
'eval mhbuild "$draft"' "mhbuild: draft shouldn't contain MIME-Version: field"
204 # Run it again using -auto
207 run_prog mhbuild
-auto "$draft"
209 cat > "$expected" <<EOF
210 To: Mr Test <mrtest@example.com>
213 Subject: Test of an already-MIMEified message
215 Content-Type: text/plain; charset="us-ascii"
217 This is a preformatted MIME content test.
220 check
"$draft" "$expected"
223 # Make sure -dist does nothing but encode headers
227 To: Señor Test <mrtest@example.com>
230 Subject: An empty dist test
233 run_prog mhbuild
-dist "$draft"
235 cat > "$expected" <<EOF
236 To: =?UTF-8?Q?Se=C3=B1or_Test?= <mrtest@example.com>
239 Subject: An empty dist test
242 check
"$draft" "$expected"
245 # Two parts, one attachment; make sure mixing of multiparts at different
250 To: Mr Test <mrtest@example.com>
253 Subject: A more complete multipart test
254 Attach: ${srcdir}/test/mhbuild/tiny.jpg
262 This is some HTML tëxt.
268 run_prog mhbuild
"$draft"
270 cat > "$expected" <<EOF
271 To: Mr Test <mrtest@example.com>
274 Subject: A more complete multipart test
276 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
277 Content-Transfer-Encoding: 8bit
279 ------- =_aaaaaaaaaa0
280 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
281 Content-Transfer-Encoding: 8bit
283 ------- =_aaaaaaaaaa1
284 Content-Type: text/plain; charset="UTF-8"
285 Content-Transfer-Encoding: 8bit
289 ------- =_aaaaaaaaaa1
290 Content-Type: text/html; charset="UTF-8"
291 Content-Transfer-Encoding: 8bit
295 This is some HTML tëxt.
299 ------- =_aaaaaaaaaa1--
301 ------- =_aaaaaaaaaa0
302 Content-Type: image/jpeg; name="tiny.jpg"
303 Content-Description: tiny.jpg
304 Content-Disposition: attachment; filename="tiny.jpg"
305 Content-Transfer-Encoding: base64
309 ------- =_aaaaaaaaaa0--
312 check
"$draft" "$expected"
315 # One attachment, text/plain containing some binary characters,
320 To: Mr Test <mrtest@example.com>
323 Subject: Testing some binary chars
326 #text/plain; name="somebinary" [ - ] {attachment} ${srcdir}/test/mhbuild/somebinary
329 run_prog mhbuild
"$draft"
331 cat > "$expected" <<EOF
332 To: Mr Test <mrtest@example.com>
335 Subject: Testing some binary chars
337 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
338 Content-Transfer-Encoding: 8bit
340 ------- =_aaaaaaaaaa0
341 Content-Type: text/plain; charset="UTF-8"
342 Content-Transfer-Encoding: 8bit
346 ------- =_aaaaaaaaaa0
347 Content-Type: text/plain; name="somebinary"; charset="us-ascii"
348 Content-Description: -
349 Content-Disposition: attachment; filename="somebinary"
350 Content-Transfer-Encoding: quoted-printable
353 =46rom here on, this is only =
355 a test, though it contains =13ome
358 ------- =_aaaaaaaaaa0--
361 check
"$draft" "$expected"
363 [ ${failed:=0} -eq 0 ] && rm -f ${backup}