From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id CC905431FAF for ; Sat, 20 Oct 2012 20:05:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 2DXwuR8tEP-3 for ; Sat, 20 Oct 2012 20:05:12 -0700 (PDT) Received: from mail-da0-f53.google.com (mail-da0-f53.google.com [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id BF7D7431FAE for ; Sat, 20 Oct 2012 20:05:11 -0700 (PDT) Received: by mail-da0-f53.google.com with SMTP id g9so1033662dad.26 for ; Sat, 20 Oct 2012 20:05:11 -0700 (PDT) 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=9Rz1NY0eWSbSG0b0AOElvKHjDqAdqCk9seBQ4OTiGOI=; b=bCM5AwX3/GoaX4IarE8GjNmsSERMtTVa4czU29F+LLSoaWhQvppIjkXlvzvbjKsZ4A Hmyz1tblAKFR0OTSxek49v4s3loVY/AxTb5F6NyhMfXnBseI4Iuvvt73TD8f7yTkhLjJ vfvfOiCbHdGQRXlzLTKLxx0bGpM7U5F5W8iOUGJNREZRZGrHodY9mEl46u85Q030QcWg +QFOMKiFwHZU5NDOO9YG+PC/tb3Qbs2L4gjZHTs+ASuG4y0l2AwII+rnB+p5B+m1hqlA +aQxtFBNevz/hF/ygX9nNezz6MPjSUz23LPEs+Jvjh4qKSi0rOZp8bRPMKse/VyFmpNy 3vrQ== Received: by 10.66.87.105 with SMTP id w9mr16302862paz.5.1350788710921; Sat, 20 Oct 2012 20:05:10 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id wg3sm3676527pbc.28.2012.10.20.20.05.08 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 20 Oct 2012 20:05:09 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH v3] test: conform to content length, encoding fields Date: Sun, 21 Oct 2012 14:04:11 +1100 Message-Id: <1350788651-10555-1-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1344428872-12374-4-git-send-email-novalazy@gmail.com> References: <1344428872-12374-4-git-send-email-novalazy@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, 21 Oct 2012 03:05:15 -0000 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 +++++---- 3 files changed, 29 insertions(+), 14 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 ac8fa8e..9911eeb 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)" -- 1.7.12.1