2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 . "$MH_OBJ_DIR/test/common.sh"
19 expected=$MH_TEST_DIR/$$.expected
20 actual=$MH_TEST_DIR/$$.actual
24 # check with no options and no current message
25 run_test 'mhstore' 'mhstore: no cur message'
27 # check with no options and current message
28 folder +inbox 5 > /dev/null
30 This is message number 5
32 run_test 'mhstore' 'storing message 5 as file 5.txt'
33 check $expected 5.txt 'keep first'
35 # check with folder and current message
36 run_test 'mhstore +inbox' 'storing message 5 as file 5.txt'
37 check $expected 5.txt 'keep first'
39 # check with specified message
40 run_test 'mhstore 5' 'storing message 5 as file 5.txt'
41 check $expected 5.txt 'keep first'
44 run_test "mhstore -file $MH_TEST_DIR/Mail/inbox/5" \
45 "storing message $MH_TEST_DIR/Mail/inbox/5 as file 5.txt"
46 check $expected 5.txt 'keep first'
49 stored_contents=`mhstore -file - < $MH_TEST_DIR/Mail/inbox/5 2>&1 | \
51 check $expected $stored_contents
53 # check message number greater than highest
54 run_test 'mhstore 11' "mhstore: message 11 doesn't exist"
56 # check multiple messages
57 run_test 'mhstore 4 6' 'storing message 4 as file 4.txt
58 storing message 6 as file 6.txt'
60 This is message number 4
64 This is message number 6
68 # Write message with a text/plain subpart.
71 To: recipient@example.com
72 From: sender@example.com
75 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
78 Content-Type: multipart/related;
79 type="multipart/alternative";
80 boundary="subpart__1.1"
83 Content-Type: text/plain; charset="iso-8859-1"
84 Content-Disposition: attachment; filename="test1.txt"
86 This is the first text/plain part, in a subpart.
91 Content-Type: text/plain; charset="iso-8859-1"
92 Content-Disposition: attachment; filename="test2.txt"
93 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
94 Content-Transfer-Encoding: quoted-printable
96 This is the second text/plain part.
99 Content-Type: text/plain; charset="iso-8859-1"
100 Content-Disposition: attachment; filename="test3.txt"
102 This is the third text/plain part.
104 ------- =_aaaaaaaaaa0
105 Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
106 Content-Disposition: attachment; filename="test4.txt"
107 Content-Transfer-Encoding: base64
109 VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
111 ------- =_aaaaaaaaaa0--
115 cat > $expected <<EOF
116 This is the third text/plain part.
118 run_test 'mhstore last -part 3' 'storing message 11 part 3 as file 11.3.txt'
119 check $expected 11.3.txt
121 # check -part of a subpart
122 cat > $expected <<EOF
123 This is the first text/plain part, in a subpart.
125 run_test 'mhstore last -part 1.1' \
126 'storing message 11 part 1.1 as file 11.1.1.txt'
127 check $expected 11.1.1.txt 'keep first'
130 run_test 'mhstore last -type text/plain' \
131 'storing message 11 part 1.1 as file 11.1.1.txt
132 storing message 11 part 2 as file 11.2.txt
133 storing message 11 part 3 as file 11.3.txt
134 storing message 11 part 4 as file 11.4.txt'
135 check $expected 11.1.1.txt
136 cat > $expected <<EOF
137 This is the second text/plain part.
139 check $expected 11.2.txt
140 cat > $expected <<EOF
141 This is the third text/plain part.
143 check $expected 11.3.txt
144 cat > $expected <<EOF
145 This is the fourth text/plain part.
147 check $expected 11.4.txt
150 cat > $expected <<EOF
151 This is the fourth text/plain part.
153 run_test 'mhstore last -part 4 -auto' \
154 'storing message 11 part 4 as file test4.txt'
155 check $expected test4.txt 'keep first'
157 # check -noauto, the default
158 run_test 'mhstore last -part 4 -auto -noauto' \
159 'storing message 11 part 4 as file 11.4.txt'
160 check $expected 11.4.txt 'keep first'
162 # check -verbose, which doesn't do anything
163 run_test 'mhstore last -part 4 -verbose' \
164 'storing message 11 part 4 as file 11.4.txt'
165 check $expected 11.4.txt 'keep first'
167 # check -noverbose, the default
168 run_test 'mhstore last -part 4 -verbose -noverbose' \
169 'storing message 11 part 4 as file 11.4.txt'
170 check $expected 11.4.txt
173 cat > $expected <<EOF
174 This is the second text/plain part.
176 run_test 'mhstore last -part 2 -check' \
177 'storing message 11 part 2 as file 11.2.txt'
178 check $expected 11.2.txt 'keep first'
180 # check -check with bad MD5 checksum
181 sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' $msgfile > $MH_TEST_DIR/$$.tmp
182 mv -f $MH_TEST_DIR/$$.tmp $msgfile
183 run_test 'mhstore last -part 2 -check' \
184 'storing message 11 part 2 as file 11.2.txt
185 mhstore: content integrity suspect (digest mismatch) -- continuing
186 (content text/plain in message 11, part 2)'
187 check $expected 11.2.txt 'keep first'
189 # check -nocheck, the default
190 run_test 'mhstore last -part 2 -check -nocheck' \
191 'storing message 11 part 2 as file 11.2.txt'
192 check $expected 11.2.txt
194 # check reassembly of message/partial messages (RFC 1521, 7.3.2)
197 To: recipient@example.com
198 From: sender@example.com
201 Content-Type: message/partial; id="test-mhstore message/partial test"; number=1
203 Content-Type: text/plain; charset="iso-8859-1"
205 This is part one of three.
210 To: recipient@example.com
211 From: sender@example.com
214 Content-Type: message/partial; id="test-mhstore message/partial test"; number=2
216 This is part two of three.
221 To: recipient@example.com
222 From: sender@example.com
225 Content-Type: message/partial; id="test-mhstore message/partial test"; number=3;
228 This is part three of three.
231 run_test 'mhstore last:3' \
232 'reassembling partials 12,13,14 to folder inbox as message 15'
234 cat > $expected <<EOF
235 This is part one of three.
236 This is part two of three.
237 This is part three of three.
239 run_test 'mhstore last' 'storing message 15 as file 15.txt'
240 check $expected 15.txt
242 # check with relative nmh-storage profile component
243 storagedir=storagedir
244 dir="$MH_TEST_DIR/Mail/inbox/$storagedir"
246 echo "nmh-storage: $storagedir" >> $MH
247 cat > $expected <<EOF
248 This is the fourth text/plain part.
250 run_test 'mhstore 11 -part 4' \
251 "storing message 11 part 4 as file $storagedir/11.4.txt"
252 check $expected "$dir/11.4.txt" 'keep first'
254 # check with relative nmh-storage profile component and -auto
255 run_test 'mhstore 11 -part 4 -auto' \
256 "storing message 11 part 4 as file $storagedir/test4.txt"
257 check $expected "$dir/test4.txt" 'keep first'
259 # check with absolute nmh-storage profile component
260 absstoragedir="$MH_TEST_DIR/$storagedir"
261 mkdir "$absstoragedir"
262 sed "s%\(nmh-storage: \)storagedir%\1$absstoragedir%" $MH > $MH.new
264 run_test 'mhstore 11 -part 4' \
265 "storing message 11 part 4 as file $storagedir/11.4.txt"
266 check $expected "$absstoragedir/11.4.txt" 'keep first'
268 # check with absolute nmh-storage profile component and -auto
269 run_test 'mhstore 11 -part 4 -auto' \
270 "storing message 11 part 4 as file $storagedir/test4.txt"
271 check $expected "$absstoragedir/test4.txt"
272 rmdir "$absstoragedir"