]>
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 LC_ALL
=en_US.UTF
-8; export LC_ALL
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 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 Attach: ${srcdir}/test/mhbuild/tiny.jpg
66 run_prog mhbuild
"$draft"
68 cat > "$expected" <<EOF
69 To: Mr Test <mrtest@example.com>
73 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
76 Content-Type: text/plain; charset="us-ascii"
81 Content-Type: image/jpeg; name="tiny.jpg"
82 Content-Description: tiny.jpg
83 Content-Disposition: attachment; filename="tiny.jpg"
84 Content-Transfer-Encoding: base64
88 ------- =_aaaaaaaaaa0--
91 check
"$draft" "$expected"
94 # An empty Attach header
98 To: Mr Test <mrtest@example.com>
103 This is a test of an empty attach header.
106 run_prog mhbuild
"$draft"
108 cat > "$expected" <<EOF
109 To: Mr Test <mrtest@example.com>
113 Content-Type: text/plain; charset="us-ascii"
115 This is a test of an empty attach header.
118 check
"$draft" "$expected"
121 # Check a completely empty message
125 To: Mr Test <mrtest@example.com>
128 Subject: Test of an empty body
131 run_prog mhbuild
"$draft"
133 cat > "$expected" <<EOF
134 To: Mr Test <mrtest@example.com>
137 Subject: Test of an empty body
139 Content-Type: text/plain
142 check
"$draft" "$expected"
145 # Make sure we fail if we run into a MIME-Version header
149 To: Mr Test <mrtest@example.com>
152 Subject: Test of an already-MIMEified message
154 Content-Type: text/plain; charset="us-ascii"
156 This is a preformatted MIME content test.
160 run_test
'eval mhbuild "$draft"' "mhbuild: draft shouldn't contain MIME-Version: field"
164 # Run it again using -auto
167 run_prog mhbuild
-auto "$draft"
169 cat > "$expected" <<EOF
170 To: Mr Test <mrtest@example.com>
173 Subject: Test of an already-MIMEified message
175 Content-Type: text/plain; charset="us-ascii"
177 This is a preformatted MIME content test.
180 check
"$draft" "$expected"
183 # Make sure -dist does nothing but encode headers
187 To: Señor Test <mrtest@example.com>
190 Subject: An empty dist test
193 run_prog mhbuild
-dist "$draft"
195 cat > "$expected" <<EOF
196 To: =?UTF-8?Q?Se=C3=B1or_Test?= <mrtest@example.com>
199 Subject: An empty dist test
202 check
"$draft" "$expected"
205 # Two parts, one attachment; make sure mixing of multiparts at different
210 To: Mr Test <mrtest@example.com>
213 Subject: A more complete multipart test
214 Attach: ${srcdir}/test/mhbuild/tiny.jpg
222 This is some HTML tëxt.
228 run_prog mhbuild
"$draft"
230 cat > "$expected" <<EOF
231 To: Mr Test <mrtest@example.com>
234 Subject: A more complete multipart test
236 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
237 Content-Transfer-Encoding: 8bit
239 ------- =_aaaaaaaaaa0
240 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
241 Content-Transfer-Encoding: 8bit
243 ------- =_aaaaaaaaaa1
244 Content-Type: text/plain; charset="UTF-8"
245 Content-Transfer-Encoding: 8bit
249 ------- =_aaaaaaaaaa1
250 Content-Type: text/html; charset="UTF-8"
251 Content-Transfer-Encoding: 8bit
255 This is some HTML tëxt.
259 ------- =_aaaaaaaaaa1--
261 ------- =_aaaaaaaaaa0
262 Content-Type: image/jpeg; name="tiny.jpg"
263 Content-Description: tiny.jpg
264 Content-Disposition: attachment; filename="tiny.jpg"
265 Content-Transfer-Encoding: base64
269 ------- =_aaaaaaaaaa0--
272 check
"$draft" "$expected"
274 [ ${failed:=0} -eq 0 ] && rm -f ${backup}