1 Return-Path: <novalazy@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 CC905431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 20 Oct 2012 20:05:15 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 2DXwuR8tEP-3 for <notmuch@notmuchmail.org>;
\r
17 Sat, 20 Oct 2012 20:05:12 -0700 (PDT)
\r
18 Received: from mail-da0-f53.google.com (mail-da0-f53.google.com
\r
19 [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id BF7D7431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 20 Oct 2012 20:05:11 -0700 (PDT)
\r
23 Received: by mail-da0-f53.google.com with SMTP id g9so1033662dad.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 20 Oct 2012 20:05:11 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
27 :mime-version:content-type:content-transfer-encoding;
\r
28 bh=9Rz1NY0eWSbSG0b0AOElvKHjDqAdqCk9seBQ4OTiGOI=;
\r
29 b=bCM5AwX3/GoaX4IarE8GjNmsSERMtTVa4czU29F+LLSoaWhQvppIjkXlvzvbjKsZ4A
\r
30 Hmyz1tblAKFR0OTSxek49v4s3loVY/AxTb5F6NyhMfXnBseI4Iuvvt73TD8f7yTkhLjJ
\r
31 vfvfOiCbHdGQRXlzLTKLxx0bGpM7U5F5W8iOUGJNREZRZGrHodY9mEl46u85Q030QcWg
\r
32 +QFOMKiFwHZU5NDOO9YG+PC/tb3Qbs2L4gjZHTs+ASuG4y0l2AwII+rnB+p5B+m1hqlA
\r
33 +aQxtFBNevz/hF/ygX9nNezz6MPjSUz23LPEs+Jvjh4qKSi0rOZp8bRPMKse/VyFmpNy
\r
35 Received: by 10.66.87.105 with SMTP id w9mr16302862paz.5.1350788710921;
\r
36 Sat, 20 Oct 2012 20:05:10 -0700 (PDT)
\r
37 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
39 by mx.google.com with ESMTPS id wg3sm3676527pbc.28.2012.10.20.20.05.08
\r
40 (version=TLSv1/SSLv3 cipher=OTHER);
\r
41 Sat, 20 Oct 2012 20:05:09 -0700 (PDT)
\r
42 From: Peter Wang <novalazy@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH v3] test: conform to content length, encoding fields
\r
45 Date: Sun, 21 Oct 2012 14:04:11 +1100
\r
46 Message-Id: <1350788651-10555-1-git-send-email-novalazy@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.12.1
\r
48 In-Reply-To: <1344428872-12374-4-git-send-email-novalazy@gmail.com>
\r
49 References: <1344428872-12374-4-git-send-email-novalazy@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, 21 Oct 2012 03:05:15 -0000
\r
67 Update tests to expect content-length and content-transfer-encoding
\r
68 fields in show --format=json output, for leaf parts with omitted body
\r
71 test/crypto | 30 +++++++++++++++++++++---------
\r
73 test/multipart | 9 +++++----
\r
74 3 files changed, 29 insertions(+), 14 deletions(-)
\r
76 diff --git a/test/crypto b/test/crypto
\r
77 index 5dd14c4..aa96ec2 100755
\r
80 @@ -61,7 +61,8 @@ expected='[[[{"id": "XXXXX",
\r
81 "content-type": "text/plain",
\r
82 "content": "This is a test signed message.\n"},
\r
84 - "content-type": "application/pgp-signature"}]}]},
\r
85 + "content-type": "application/pgp-signature",
\r
86 + "content-length": 315}]}]},
\r
88 test_expect_equal_json \
\r
90 @@ -95,7 +96,8 @@ expected='[[[{"id": "XXXXX",
\r
91 "content-type": "text/plain",
\r
92 "content": "This is a test signed message.\n"},
\r
94 - "content-type": "application/pgp-signature"}]}]},
\r
95 + "content-type": "application/pgp-signature",
\r
96 + "content-length": 315}]}]},
\r
98 test_expect_equal_json \
\r
100 @@ -127,7 +129,8 @@ expected='[[[{"id": "XXXXX",
\r
101 "content-type": "text/plain",
\r
102 "content": "This is a test signed message.\n"},
\r
104 - "content-type": "application/pgp-signature"}]}]},
\r
105 + "content-type": "application/pgp-signature",
\r
106 + "content-length": 315}]}]},
\r
108 test_expect_equal_json \
\r
110 @@ -196,7 +199,8 @@ expected='[[[{"id": "XXXXX",
\r
112 "content-type": "multipart/encrypted",
\r
113 "content": [{"id": 2,
\r
114 - "content-type": "application/pgp-encrypted"},
\r
115 + "content-type": "application/pgp-encrypted",
\r
116 + "content-length": 11},
\r
118 "content-type": "multipart/mixed",
\r
119 "content": [{"id": 4,
\r
120 @@ -204,6 +208,8 @@ expected='[[[{"id": "XXXXX",
\r
121 "content": "This is a test encrypted message.\n"},
\r
123 "content-type": "application/octet-stream",
\r
124 + "content-length": 28,
\r
125 + "content-transfer-encoding": "base64",
\r
126 "filename": "TESTATTACHMENT"}]}]}]},
\r
128 test_expect_equal_json \
\r
129 @@ -231,9 +237,11 @@ test_expect_equal_file OUTPUT TESTATTACHMENT
\r
131 test_begin_subtest "decryption failure with missing key"
\r
132 mv "${GNUPGHOME}"{,.bak}
\r
133 +# The length of the encrypted attachment varies so must be normalized.
\r
134 output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \
\r
135 | notmuch_json_show_sanitize \
\r
136 - | sed -e 's|"created": [1234567890]*|"created": 946728000|')
\r
137 + | sed -e 's|"created": [1234567890]*|"created": 946728000|' \
\r
138 + | sed -e 's|"content-length": 6[1234567890]*|"content-length": 652|')
\r
139 expected='[[[{"id": "XXXXX",
\r
142 @@ -249,9 +257,11 @@ expected='[[[{"id": "XXXXX",
\r
143 "encstatus": [{"status": "bad"}],
\r
144 "content-type": "multipart/encrypted",
\r
145 "content": [{"id": 2,
\r
146 - "content-type": "application/pgp-encrypted"},
\r
147 + "content-type": "application/pgp-encrypted",
\r
148 + "content-length": 11},
\r
150 - "content-type": "application/octet-stream"}]}]},
\r
151 + "content-type": "application/octet-stream",
\r
152 + "content-length": 652}]}]},
\r
154 test_expect_equal_json \
\r
156 @@ -287,7 +297,8 @@ expected='[[[{"id": "XXXXX",
\r
157 "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],
\r
158 "content-type": "multipart/encrypted",
\r
159 "content": [{"id": 2,
\r
160 - "content-type": "application/pgp-encrypted"},
\r
161 + "content-type": "application/pgp-encrypted",
\r
162 + "content-length": 11},
\r
164 "content-type": "text/plain",
\r
165 "content": "This is another test encrypted message.\n"}]}]},
\r
166 @@ -342,7 +353,8 @@ expected='[[[{"id": "XXXXX",
\r
167 "content-type": "text/plain",
\r
168 "content": "This is a test signed message.\n"},
\r
170 - "content-type": "application/pgp-signature"}]}]},
\r
171 + "content-type": "application/pgp-signature",
\r
172 + "content-length": 315}]}]},
\r
174 test_expect_equal_json \
\r
176 diff --git a/test/json b/test/json
\r
177 index ac8fa8e..9911eeb 100755
\r
180 @@ -45,7 +45,9 @@ emacs_deliver_message \
\r
181 (insert \"Message-ID: <$id>\n\")"
\r
182 output=$(notmuch show --format=json "id:$id")
\r
183 filename=$(notmuch search --output=files "id:$id")
\r
184 -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
185 +# Get length of README after base64-encoding, minus additional newline.
\r
186 +attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))
\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\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"
\r
189 test_begin_subtest "Search message: json, utf-8"
\r
190 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
191 diff --git a/test/multipart b/test/multipart
\r
192 index 344ed81..497f3ec 100755
\r
193 --- a/test/multipart
\r
194 +++ b/test/multipart
\r
195 @@ -330,7 +330,7 @@ cat <<EOF >EXPECTED
\r
196 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
\r
197 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"},
\r
198 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
199 -{"id": 9, "content-type": "application/pgp-signature"}]}]}
\r
200 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}
\r
202 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
204 @@ -345,7 +345,7 @@ cat <<EOF >EXPECTED
\r
205 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
\r
206 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"},
\r
207 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
208 -{"id": 9, "content-type": "application/pgp-signature"}]}
\r
209 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}
\r
211 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
213 @@ -412,7 +412,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
214 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
\r
215 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
\r
216 cat <<EOF >EXPECTED
\r
217 -{"id": 9, "content-type": "application/pgp-signature"}
\r
218 +{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}
\r
220 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
222 @@ -636,7 +636,8 @@ cat <<EOF >EXPECTED
\r
223 "content-type": "text/plain",
\r
224 "content": "And this message is signed.\n\n-Carl\n"}]},
\r
226 - "content-type": "application/pgp-signature"}]}]}}
\r
227 + "content-type": "application/pgp-signature",
\r
228 + "content-length": 197}]}]}}
\r
230 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r