[PATCH v5 4/4] test: conform to content length, encoding fields
authorPeter Wang <novalazy@gmail.com>
Sat, 15 Dec 2012 03:06:45 +0000 (14:06 +1100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:12 +0000 (09:52 -0800)
bb/a8428b9f68f142db0b200e6bd1e6f248a3fff9 [new file with mode: 0644]

diff --git a/bb/a8428b9f68f142db0b200e6bd1e6f248a3fff9 b/bb/a8428b9f68f142db0b200e6bd1e6f248a3fff9
new file mode 100644 (file)
index 0000000..79e08b6
--- /dev/null
@@ -0,0 +1,306 @@
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 46951431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:08:22 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id aL6Rxk0IWFix for <notmuch@notmuchmail.org>;\r
+       Fri, 14 Dec 2012 19:08:18 -0800 (PST)\r
+Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com\r
+       [209.85.220.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id AF0DE431FC7\r
+       for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:08:13 -0800 (PST)\r
+Received: by mail-pa0-f53.google.com with SMTP id hz1so2634858pad.26\r
+       for <notmuch@notmuchmail.org>; Fri, 14 Dec 2012 19:08:13 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+       :mime-version:content-type:content-transfer-encoding;\r
+       bh=a2JacFwzT2xFwrLJHUQawB1VoC4YUmj7kWBLPwv5bbM=;\r
+       b=RWcMEpxsD+Yt8b+jOeZNsdex+h8sIky/Qt3S4RGo/qy10s2YU3O49Pehl2TdwJemJV\r
+       nVyPN74g0Z3eEZnpYordmpp6FqfvIh0MGrdi3VwRbfLVALqAmCMCW1AH+J5QGxk+dkvH\r
+       ejOUv/Ys2Ht9KvY046kaVhlxtZzQvMcr6muuLmY56ShhCuY1w2/2Hr9NcrYUVrzWNiFg\r
+       0AY2T45X+ZAvIOOhj/ThPCgx4EvAYPDAqcz47wuMKfaMOcCOalCty/gf6iwWy/Z7cd48\r
+       X70qrlMxfrdBYlQCwEKygGyVMVmp6BYoPKXcK94Wph5K/iO5atpqzSYT3q1SxX7sWKpx\r
+       jCjg==\r
+Received: by 10.68.132.98 with SMTP id ot2mr21372214pbb.39.1355540892984;\r
+       Fri, 14 Dec 2012 19:08:12 -0800 (PST)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPS id mn5sm3945009pbc.12.2012.12.14.19.08.06\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 14 Dec 2012 19:08:12 -0800 (PST)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v5 4/4] test: conform to content length, encoding fields\r
+Date: Sat, 15 Dec 2012 14:06:45 +1100\r
+Message-Id: <1355540805-24937-5-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.12.1\r
+In-Reply-To: <1355540805-24937-1-git-send-email-novalazy@gmail.com>\r
+References: <1355540805-24937-1-git-send-email-novalazy@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 15 Dec 2012 03:08:22 -0000\r
+\r
+Update tests to expect content-length and content-transfer-encoding\r
+fields in show --format=json output, for leaf parts with omitted body\r
+content.\r
+---\r
+ test/crypto    | 30 +++++++++++++++++++++---------\r
+ test/json      |  4 +++-\r
+ test/multipart | 24 +++++++++++++-----------\r
+ test/sexp      |  4 +++-\r
+ 4 files changed, 40 insertions(+), 22 deletions(-)\r
+\r
+diff --git a/test/crypto b/test/crypto\r
+index 5dd14c4..aa96ec2 100755\r
+--- a/test/crypto\r
++++ b/test/crypto\r
+@@ -61,7 +61,8 @@ expected='[[[{"id": "XXXXX",\r
+  "content-type": "text/plain",\r
+  "content": "This is a test signed message.\n"},\r
+  {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+     "$output" \\r
+@@ -95,7 +96,8 @@ expected='[[[{"id": "XXXXX",\r
+  "content-type": "text/plain",\r
+  "content": "This is a test signed message.\n"},\r
+  {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+     "$output" \\r
+@@ -127,7 +129,8 @@ expected='[[[{"id": "XXXXX",\r
+  "content-type": "text/plain",\r
+  "content": "This is a test signed message.\n"},\r
+  {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+     "$output" \\r
+@@ -196,7 +199,8 @@ expected='[[[{"id": "XXXXX",\r
+  "sigstatus": [],\r
+  "content-type": "multipart/encrypted",\r
+  "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+  {"id": 3,\r
+  "content-type": "multipart/mixed",\r
+  "content": [{"id": 4,\r
+@@ -204,6 +208,8 @@ expected='[[[{"id": "XXXXX",\r
+  "content": "This is a test encrypted message.\n"},\r
+  {"id": 5,\r
+  "content-type": "application/octet-stream",\r
++ "content-length": 28,\r
++ "content-transfer-encoding": "base64",\r
+  "filename": "TESTATTACHMENT"}]}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+@@ -231,9 +237,11 @@ test_expect_equal_file OUTPUT TESTATTACHMENT\r
\r
+ test_begin_subtest "decryption failure with missing key"\r
+ mv "${GNUPGHOME}"{,.bak}\r
++# The length of the encrypted attachment varies so must be normalized.\r
+ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \\r
+     | notmuch_json_show_sanitize \\r
+-    | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
++    | sed -e 's|"created": [1234567890]*|"created": 946728000|' \\r
++    | sed -e 's|"content-length": 6[1234567890]*|"content-length": 652|')\r
+ expected='[[[{"id": "XXXXX",\r
+  "match": true,\r
+  "excluded": false,\r
+@@ -249,9 +257,11 @@ expected='[[[{"id": "XXXXX",\r
+  "encstatus": [{"status": "bad"}],\r
+  "content-type": "multipart/encrypted",\r
+  "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+  {"id": 3,\r
+- "content-type": "application/octet-stream"}]}]},\r
++ "content-type": "application/octet-stream",\r
++ "content-length": 652}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+     "$output" \\r
+@@ -287,7 +297,8 @@ expected='[[[{"id": "XXXXX",\r
+  "userid": " Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!)"}],\r
+  "content-type": "multipart/encrypted",\r
+  "content": [{"id": 2,\r
+- "content-type": "application/pgp-encrypted"},\r
++ "content-type": "application/pgp-encrypted",\r
++ "content-length": 11},\r
+  {"id": 3,\r
+  "content-type": "text/plain",\r
+  "content": "This is another test encrypted message.\n"}]}]},\r
+@@ -342,7 +353,8 @@ expected='[[[{"id": "XXXXX",\r
+  "content-type": "text/plain",\r
+  "content": "This is a test signed message.\n"},\r
+  {"id": 3,\r
+- "content-type": "application/pgp-signature"}]}]},\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 315}]}]},\r
+  []]]]'\r
+ test_expect_equal_json \\r
+     "$output" \\r
+diff --git a/test/json b/test/json\r
+index bfafd55..ff7fbe1 100755\r
+--- a/test/json\r
++++ b/test/json\r
+@@ -45,7 +45,9 @@ emacs_deliver_message \\r
+      (insert \"Message-ID: <$id>\n\")"\r
+ output=$(notmuch show --format=json "id:$id")\r
+ filename=$(notmuch search --output=files "id:$id")\r
+-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
++# Get length of README after base64-encoding, minus additional newline.\r
++attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))\r
++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
\r
+ test_begin_subtest "Search message: json, utf-8"\r
+ 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
+diff --git a/test/multipart b/test/multipart\r
+index 344ed81..c974226 100755\r
+--- a/test/multipart\r
++++ b/test/multipart\r
+@@ -326,11 +326,11 @@ cat <<EOF >EXPECTED\r
+ {"id": 2, "content-type": "multipart/mixed", "content": [\r
+ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
+ {"id": 4, "content-type": "multipart/alternative", "content": [\r
+-{"id": 5, "content-type": "text/html"}, \r
++{"id": 5, "content-type": "text/html", "content-length": 71},\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
+ {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
+ {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
+-{"id": 9, "content-type": "application/pgp-signature"}]}]}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
\r
+@@ -341,11 +341,11 @@ cat <<EOF >EXPECTED\r
+ {"id": 2, "content-type": "multipart/mixed", "content": [\r
+ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
+ {"id": 4, "content-type": "multipart/alternative", "content": [\r
+-{"id": 5, "content-type": "text/html"}, \r
++{"id": 5, "content-type": "text/html", "content-length": 71},\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
+ {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
+ {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
+-{"id": 9, "content-type": "application/pgp-signature"}]}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
\r
+@@ -355,7 +355,7 @@ cat <<EOF >EXPECTED\r
+ {"id": 2, "content-type": "multipart/mixed", "content": [\r
+ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
+ {"id": 4, "content-type": "multipart/alternative", "content": [\r
+-{"id": 5, "content-type": "text/html"}, \r
++{"id": 5, "content-type": "text/html", "content-length": 71},\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
+ {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
+ {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}\r
+@@ -367,7 +367,7 @@ notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OU\r
+ cat <<EOF >EXPECTED\r
+ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
+ {"id": 4, "content-type": "multipart/alternative", "content": [\r
+-{"id": 5, "content-type": "text/html"}, \r
++{"id": 5, "content-type": "text/html", "content-length": 71},\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+@@ -376,7 +376,7 @@ test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"\r
+ notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+ {"id": 4, "content-type": "multipart/alternative", "content": [\r
+-{"id": 5, "content-type": "text/html"}, \r
++{"id": 5, "content-type": "text/html", "content-length": 71},\r
+ {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+@@ -384,7 +384,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ test_begin_subtest "--format=json --part=5, rfc822's html part"\r
+ notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-{"id": 5, "content-type": "text/html"}\r
++{"id": 5, "content-type": "text/html", "content-length": 71}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
\r
+@@ -412,7 +412,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
+ test_begin_subtest "--format=json --part=9, pgp signature (unverified)"\r
+ notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-{"id": 9, "content-type": "application/pgp-signature"}\r
++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
\r
+@@ -624,7 +624,8 @@ cat <<EOF >EXPECTED\r
+  "body": [{"id": 4,\r
+  "content-type": "multipart/alternative",\r
+  "content": [{"id": 5,\r
+- "content-type": "text/html"},\r
++ "content-type": "text/html",\r
++ "content-length": 71},\r
+  {"id": 6,\r
+  "content-type": "text/plain",\r
+  "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},\r
+@@ -636,7 +637,8 @@ cat <<EOF >EXPECTED\r
+  "content-type": "text/plain",\r
+  "content": "And this message is signed.\n\n-Carl\n"}]},\r
+  {"id": 9,\r
+- "content-type": "application/pgp-signature"}]}]}}\r
++ "content-type": "application/pgp-signature",\r
++ "content-length": 197}]}]}}\r
+ EOF\r
+ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
\r
+diff --git a/test/sexp b/test/sexp\r
+index b804942..492a82f 100755\r
+--- a/test/sexp\r
++++ b/test/sexp\r
+@@ -37,7 +37,9 @@ emacs_deliver_message \\r
+      (insert \"Message-ID: <$id>\n\")"\r
+ output=$(notmuch show --format=sexp "id:$id")\r
+ filename=$(notmuch search --output=files "id:$id")\r
+-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
++# Get length of README after base64-encoding, minus additional newline.\r
++attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))\r
++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-transfer-encoding \"base64\" :content-length $attachment_length))))) ())))"\r
\r
+ test_begin_subtest "Search message: sexp, utf-8"\r
+ 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
+-- \r
+1.7.12.1\r
+\r