1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 37A5B431FBF
\r
6 for <notmuch@notmuchmail.org>; Sun, 9 Dec 2012 04:56:55 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id ljS6TnWQjY+h for <notmuch@notmuchmail.org>;
\r
18 Sun, 9 Dec 2012 04:56:53 -0800 (PST)
\r
19 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com
\r
20 [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 085C5431FBC
\r
23 for <notmuch@notmuchmail.org>; Sun, 9 Dec 2012 04:56:52 -0800 (PST)
\r
24 Received: by mail-wi0-f175.google.com with SMTP id hm11so531623wib.2
\r
25 for <notmuch@notmuchmail.org>; Sun, 09 Dec 2012 04:56:51 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
28 :mime-version:content-type:content-transfer-encoding;
\r
29 bh=HviFIyYvXTWT4yAsWe7JDeucbV82uP8THLTJez0NbZ4=;
\r
30 b=dbNc/J9bNI5BLUdNfffvZfUfh/DP9xPQZkX1AWvyNZQuNfXLQK4aFnjLg+UhgYDeoX
\r
31 ZKi+OscAhnSN5A0PvP5j8nWaErhcK8niN1VkjL72M4RqRC56BNJMjQa6i+mDE+eEimgB
\r
32 gF2oKPO8TRuPLZNuecP7aOnYMjR9YuUps7OecOhydBMGBoJeFnImV78oJXIHq/P3I5xB
\r
33 gOfhvd+5Ty8r5rfclA560Yy/3FR8UIBWbksmk5A+FE/5hRhHAs5myRFtaK+ZCvhdF775
\r
34 y+kKHKtaSIfzW2TN5Js1CBH7LItmKTknHDeJ5MrRC8/bgTHJ1o5GTWI1g0R7q7W49ROd
\r
36 Received: by 10.180.109.132 with SMTP id hs4mr6390187wib.1.1355057811865;
\r
37 Sun, 09 Dec 2012 04:56:51 -0800 (PST)
\r
38 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
39 by mx.google.com with ESMTPS id cf6sm6809099wib.3.2012.12.09.04.56.50
\r
40 (version=TLSv1/SSLv3 cipher=OTHER);
\r
41 Sun, 09 Dec 2012 04:56:51 -0800 (PST)
\r
42 From: Mark Walters <markwalters1009@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH v4 3/3] test: conform to content length, encoding fields
\r
45 Date: Sun, 9 Dec 2012 12:56:36 +0000
\r
46 Message-Id: <1355057796-19260-4-git-send-email-markwalters1009@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.9.1
\r
48 In-Reply-To: <1355057796-19260-1-git-send-email-markwalters1009@gmail.com>
\r
49 References: <1355057796-19260-1-git-send-email-markwalters1009@gmail.com>
\r
51 Content-Type: text/plain; charset=UTF-8
\r
52 Content-Transfer-Encoding: 8bit
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Sun, 09 Dec 2012 12:56:55 -0000
\r
67 From: Peter Wang <novalazy@gmail.com>
\r
69 Update tests to expect content-length and content-transfer-encoding
\r
70 fields in show --format=json output, for leaf parts with omitted body
\r
73 test/crypto | 30 +++++++++++++++++++++---------
\r
75 test/multipart | 9 +++++----
\r
77 4 files changed, 30 insertions(+), 15 deletions(-)
\r
79 diff --git a/test/crypto b/test/crypto
\r
80 index 5dd14c4..aa96ec2 100755
\r
83 @@ -61,7 +61,8 @@ expected='[[[{"id": "XXXXX",
\r
84 "content-type": "text/plain",
\r
85 "content": "This is a test signed message.\n"},
\r
87 - "content-type": "application/pgp-signature"}]}]},
\r
88 + "content-type": "application/pgp-signature",
\r
89 + "content-length": 315}]}]},
\r
91 test_expect_equal_json \
\r
93 @@ -95,7 +96,8 @@ expected='[[[{"id": "XXXXX",
\r
94 "content-type": "text/plain",
\r
95 "content": "This is a test signed message.\n"},
\r
97 - "content-type": "application/pgp-signature"}]}]},
\r
98 + "content-type": "application/pgp-signature",
\r
99 + "content-length": 315}]}]},
\r
101 test_expect_equal_json \
\r
103 @@ -127,7 +129,8 @@ expected='[[[{"id": "XXXXX",
\r
104 "content-type": "text/plain",
\r
105 "content": "This is a test signed message.\n"},
\r
107 - "content-type": "application/pgp-signature"}]}]},
\r
108 + "content-type": "application/pgp-signature",
\r
109 + "content-length": 315}]}]},
\r
111 test_expect_equal_json \
\r
113 @@ -196,7 +199,8 @@ expected='[[[{"id": "XXXXX",
\r
115 "content-type": "multipart/encrypted",
\r
116 "content": [{"id": 2,
\r
117 - "content-type": "application/pgp-encrypted"},
\r
118 + "content-type": "application/pgp-encrypted",
\r
119 + "content-length": 11},
\r
121 "content-type": "multipart/mixed",
\r
122 "content": [{"id": 4,
\r
123 @@ -204,6 +208,8 @@ expected='[[[{"id": "XXXXX",
\r
124 "content": "This is a test encrypted message.\n"},
\r
126 "content-type": "application/octet-stream",
\r
127 + "content-length": 28,
\r
128 + "content-transfer-encoding": "base64",
\r
129 "filename": "TESTATTACHMENT"}]}]}]},
\r
131 test_expect_equal_json \
\r
132 @@ -231,9 +237,11 @@ test_expect_equal_file OUTPUT TESTATTACHMENT
\r
134 test_begin_subtest "decryption failure with missing key"
\r
135 mv "${GNUPGHOME}"{,.bak}
\r
136 +# The length of the encrypted attachment varies so must be normalized.
\r
137 output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \
\r
138 | notmuch_json_show_sanitize \
\r
139 - | sed -e 's|"created": [1234567890]*|"created": 946728000|')
\r
140 + | sed -e 's|"created": [1234567890]*|"created": 946728000|' \
\r
141 + | sed -e 's|"content-length": 6[1234567890]*|"content-length": 652|')
\r
142 expected='[[[{"id": "XXXXX",
\r
145 @@ -249,9 +257,11 @@ expected='[[[{"id": "XXXXX",
\r
146 "encstatus": [{"status": "bad"}],
\r
147 "content-type": "multipart/encrypted",
\r
148 "content": [{"id": 2,
\r
149 - "content-type": "application/pgp-encrypted"},
\r
150 + "content-type": "application/pgp-encrypted",
\r
151 + "content-length": 11},
\r
153 - "content-type": "application/octet-stream"}]}]},
\r
154 + "content-type": "application/octet-stream",
\r
155 + "content-length": 652}]}]},
\r
157 test_expect_equal_json \
\r
159 @@ -287,7 +297,8 @@ expected='[[[{"id": "XXXXX",
\r
160 "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],
\r
161 "content-type": "multipart/encrypted",
\r
162 "content": [{"id": 2,
\r
163 - "content-type": "application/pgp-encrypted"},
\r
164 + "content-type": "application/pgp-encrypted",
\r
165 + "content-length": 11},
\r
167 "content-type": "text/plain",
\r
168 "content": "This is another test encrypted message.\n"}]}]},
\r
169 @@ -342,7 +353,8 @@ expected='[[[{"id": "XXXXX",
\r
170 "content-type": "text/plain",
\r
171 "content": "This is a test signed message.\n"},
\r
173 - "content-type": "application/pgp-signature"}]}]},
\r
174 + "content-type": "application/pgp-signature",
\r
175 + "content-length": 315}]}]},
\r
177 test_expect_equal_json \
\r
179 diff --git a/test/json b/test/json
\r
180 index bfafd55..ff7fbe1 100755
\r
183 @@ -45,7 +45,9 @@ emacs_deliver_message \
\r
184 (insert \"Message-ID: <$id>\n\")"
\r
185 output=$(notmuch show --format=json "id:$id")
\r
186 filename=$(notmuch search --output=files "id:$id")
\r
187 -test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"README\"}]}]}, []]]]"
\r
188 +# Get length of README after base64-encoding, minus additional newline.
\r
189 +attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))
\r
190 +test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"
\r
192 test_begin_subtest "Search message: json, utf-8"
\r
193 add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
\r
194 diff --git a/test/multipart b/test/multipart
\r
195 index 344ed81..497f3ec 100755
\r
196 --- a/test/multipart
\r
197 +++ b/test/multipart
\r
198 @@ -330,7 +330,7 @@ cat <<EOF >EXPECTED
\r
199 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
\r
200 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"},
\r
201 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
202 -{"id": 9, "content-type": "application/pgp-signature"}]}]}
\r
203 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}
\r
205 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
207 @@ -345,7 +345,7 @@ cat <<EOF >EXPECTED
\r
208 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
\r
209 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"},
\r
210 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
211 -{"id": 9, "content-type": "application/pgp-signature"}]}
\r
212 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}
\r
214 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
216 @@ -412,7 +412,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
217 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
\r
218 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
\r
219 cat <<EOF >EXPECTED
\r
220 -{"id": 9, "content-type": "application/pgp-signature"}
\r
221 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}
\r
223 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
225 @@ -636,7 +636,8 @@ cat <<EOF >EXPECTED
\r
226 "content-type": "text/plain",
\r
227 "content": "And this message is signed.\n\n-Carl\n"}]},
\r
229 - "content-type": "application/pgp-signature"}]}]}}
\r
230 + "content-type": "application/pgp-signature",
\r
231 + "content-length": 197}]}]}}
\r
233 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
235 diff --git a/test/sexp b/test/sexp
\r
236 index b804942..dc52e79 100755
\r
239 @@ -37,7 +37,7 @@ emacs_deliver_message \
\r
240 (insert \"Message-ID: <$id>\n\")"
\r
241 output=$(notmuch show --format=sexp "id:$id")
\r
242 filename=$(notmuch search --output=files "id:$id")
\r
243 -test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :filename \"README\"))))) ())))"
\r
244 +test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :filename \"README\" :content-length 12555 :content-transfer-encoding \"base64\"))))) ())))"
\r
246 test_begin_subtest "Search message: sexp, utf-8"
\r
247 add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
\r