From 108a76aeb97f1f6fa07f003cae93d17104b3d176 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 9 Dec 2012 12:56:36 +0000 Subject: [PATCH] [PATCH v4 3/3] test: conform to content length, encoding fields --- a9/16572b20e8872c55c6edc027fdce299aee46e9 | 250 ++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 a9/16572b20e8872c55c6edc027fdce299aee46e9 diff --git a/a9/16572b20e8872c55c6edc027fdce299aee46e9 b/a9/16572b20e8872c55c6edc027fdce299aee46e9 new file mode 100644 index 000000000..8fa55b28d --- /dev/null +++ b/a9/16572b20e8872c55c6edc027fdce299aee46e9 @@ -0,0 +1,250 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 37A5B431FBF + for ; Sun, 9 Dec 2012 04:56:55 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id ljS6TnWQjY+h for ; + Sun, 9 Dec 2012 04:56:53 -0800 (PST) +Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com + [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 085C5431FBC + for ; Sun, 9 Dec 2012 04:56:52 -0800 (PST) +Received: by mail-wi0-f175.google.com with SMTP id hm11so531623wib.2 + for ; Sun, 09 Dec 2012 04:56:51 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :mime-version:content-type:content-transfer-encoding; + bh=HviFIyYvXTWT4yAsWe7JDeucbV82uP8THLTJez0NbZ4=; + b=dbNc/J9bNI5BLUdNfffvZfUfh/DP9xPQZkX1AWvyNZQuNfXLQK4aFnjLg+UhgYDeoX + ZKi+OscAhnSN5A0PvP5j8nWaErhcK8niN1VkjL72M4RqRC56BNJMjQa6i+mDE+eEimgB + gF2oKPO8TRuPLZNuecP7aOnYMjR9YuUps7OecOhydBMGBoJeFnImV78oJXIHq/P3I5xB + gOfhvd+5Ty8r5rfclA560Yy/3FR8UIBWbksmk5A+FE/5hRhHAs5myRFtaK+ZCvhdF775 + y+kKHKtaSIfzW2TN5Js1CBH7LItmKTknHDeJ5MrRC8/bgTHJ1o5GTWI1g0R7q7W49ROd + OLCg== +Received: by 10.180.109.132 with SMTP id hs4mr6390187wib.1.1355057811865; + Sun, 09 Dec 2012 04:56:51 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPS id cf6sm6809099wib.3.2012.12.09.04.56.50 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 09 Dec 2012 04:56:51 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 3/3] test: conform to content length, encoding fields +Date: Sun, 9 Dec 2012 12:56:36 +0000 +Message-Id: <1355057796-19260-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1355057796-19260-1-git-send-email-markwalters1009@gmail.com> +References: <1355057796-19260-1-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 09 Dec 2012 12:56:55 -0000 + +From: Peter Wang + +Update tests to expect content-length and content-transfer-encoding +fields in show --format=json output, for leaf parts with omitted body +content. +--- + test/crypto | 30 +++++++++++++++++++++--------- + test/json | 4 +++- + test/multipart | 9 +++++---- + test/sexp | 2 +- + 4 files changed, 30 insertions(+), 15 deletions(-) + +diff --git a/test/crypto b/test/crypto +index 5dd14c4..aa96ec2 100755 +--- a/test/crypto ++++ b/test/crypto +@@ -61,7 +61,8 @@ expected='[[[{"id": "XXXXX", + "content-type": "text/plain", + "content": "This is a test signed message.\n"}, + {"id": 3, +- "content-type": "application/pgp-signature"}]}]}, ++ "content-type": "application/pgp-signature", ++ "content-length": 315}]}]}, + []]]]' + test_expect_equal_json \ + "$output" \ +@@ -95,7 +96,8 @@ expected='[[[{"id": "XXXXX", + "content-type": "text/plain", + "content": "This is a test signed message.\n"}, + {"id": 3, +- "content-type": "application/pgp-signature"}]}]}, ++ "content-type": "application/pgp-signature", ++ "content-length": 315}]}]}, + []]]]' + test_expect_equal_json \ + "$output" \ +@@ -127,7 +129,8 @@ expected='[[[{"id": "XXXXX", + "content-type": "text/plain", + "content": "This is a test signed message.\n"}, + {"id": 3, +- "content-type": "application/pgp-signature"}]}]}, ++ "content-type": "application/pgp-signature", ++ "content-length": 315}]}]}, + []]]]' + test_expect_equal_json \ + "$output" \ +@@ -196,7 +199,8 @@ expected='[[[{"id": "XXXXX", + "sigstatus": [], + "content-type": "multipart/encrypted", + "content": [{"id": 2, +- "content-type": "application/pgp-encrypted"}, ++ "content-type": "application/pgp-encrypted", ++ "content-length": 11}, + {"id": 3, + "content-type": "multipart/mixed", + "content": [{"id": 4, +@@ -204,6 +208,8 @@ expected='[[[{"id": "XXXXX", + "content": "This is a test encrypted message.\n"}, + {"id": 5, + "content-type": "application/octet-stream", ++ "content-length": 28, ++ "content-transfer-encoding": "base64", + "filename": "TESTATTACHMENT"}]}]}]}, + []]]]' + test_expect_equal_json \ +@@ -231,9 +237,11 @@ test_expect_equal_file OUTPUT TESTATTACHMENT + + test_begin_subtest "decryption failure with missing key" + mv "${GNUPGHOME}"{,.bak} ++# The length of the encrypted attachment varies so must be normalized. + output=$(notmuch show --format=json --decrypt subject:"test encrypted message 001" \ + | notmuch_json_show_sanitize \ +- | sed -e 's|"created": [1234567890]*|"created": 946728000|') ++ | sed -e 's|"created": [1234567890]*|"created": 946728000|' \ ++ | sed -e 's|"content-length": 6[1234567890]*|"content-length": 652|') + expected='[[[{"id": "XXXXX", + "match": true, + "excluded": false, +@@ -249,9 +257,11 @@ expected='[[[{"id": "XXXXX", + "encstatus": [{"status": "bad"}], + "content-type": "multipart/encrypted", + "content": [{"id": 2, +- "content-type": "application/pgp-encrypted"}, ++ "content-type": "application/pgp-encrypted", ++ "content-length": 11}, + {"id": 3, +- "content-type": "application/octet-stream"}]}]}, ++ "content-type": "application/octet-stream", ++ "content-length": 652}]}]}, + []]]]' + test_expect_equal_json \ + "$output" \ +@@ -287,7 +297,8 @@ expected='[[[{"id": "XXXXX", + "userid": " Notmuch Test Suite (INSECURE!)"}], + "content-type": "multipart/encrypted", + "content": [{"id": 2, +- "content-type": "application/pgp-encrypted"}, ++ "content-type": "application/pgp-encrypted", ++ "content-length": 11}, + {"id": 3, + "content-type": "text/plain", + "content": "This is another test encrypted message.\n"}]}]}, +@@ -342,7 +353,8 @@ expected='[[[{"id": "XXXXX", + "content-type": "text/plain", + "content": "This is a test signed message.\n"}, + {"id": 3, +- "content-type": "application/pgp-signature"}]}]}, ++ "content-type": "application/pgp-signature", ++ "content-length": 315}]}]}, + []]]]' + test_expect_equal_json \ + "$output" \ +diff --git a/test/json b/test/json +index bfafd55..ff7fbe1 100755 +--- a/test/json ++++ b/test/json +@@ -45,7 +45,9 @@ emacs_deliver_message \ + (insert \"Message-ID: <$id>\n\")" + output=$(notmuch show --format=json "id:$id") + filename=$(notmuch search --output=files "id:$id") +-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 \", \"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\"}]}]}, []]]]" ++# Get length of README after base64-encoding, minus additional newline. ++attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 )) ++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 \", \"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\"}]}]}, []]]]" + + test_begin_subtest "Search message: json, utf-8" + 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\"" +diff --git a/test/multipart b/test/multipart +index 344ed81..497f3ec 100755 +--- a/test/multipart ++++ b/test/multipart +@@ -330,7 +330,7 @@ cat <EXPECTED + {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, + {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, + {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, +-{"id": 9, "content-type": "application/pgp-signature"}]}]} ++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]}]} + EOF + test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" + +@@ -345,7 +345,7 @@ cat <EXPECTED + {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, + {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, + {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, +-{"id": 9, "content-type": "application/pgp-signature"}]} ++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197}]} + EOF + test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" + +@@ -412,7 +412,7 @@ test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" + test_begin_subtest "--format=json --part=9, pgp signature (unverified)" + notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT + cat <EXPECTED +-{"id": 9, "content-type": "application/pgp-signature"} ++{"id": 9, "content-type": "application/pgp-signature", "content-length": 197} + EOF + test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" + +@@ -636,7 +636,8 @@ cat <EXPECTED + "content-type": "text/plain", + "content": "And this message is signed.\n\n-Carl\n"}]}, + {"id": 9, +- "content-type": "application/pgp-signature"}]}]}} ++ "content-type": "application/pgp-signature", ++ "content-length": 197}]}]}} + EOF + test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)" + +diff --git a/test/sexp b/test/sexp +index b804942..dc52e79 100755 +--- a/test/sexp ++++ b/test/sexp +@@ -37,7 +37,7 @@ emacs_deliver_message \ + (insert \"Message-ID: <$id>\n\")" + output=$(notmuch show --format=sexp "id:$id") + filename=$(notmuch search --output=files "id:$id") +-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 \" :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\"))))) ())))" ++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 \" :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\"))))) ())))" + + test_begin_subtest "Search message: sexp, utf-8" + 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\"" +-- +1.7.9.1 + -- 2.26.2