[PATCH v4 14/16] test indexing cleartext version of delivered messages.
[notmuch-archives.git] / f4 / 6883a28bba91841c967ead3fdd5eaf223cb301
diff --git a/f4/6883a28bba91841c967ead3fdd5eaf223cb301 b/f4/6883a28bba91841c967ead3fdd5eaf223cb301
new file mode 100644 (file)
index 0000000..edfe7b9
--- /dev/null
@@ -0,0 +1,197 @@
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id B22026DE096A\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 03:13:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.077\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.077 tagged_above=-999 required=5 tests=[AWL=0.077]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Nc2CGxPamK2e for <notmuch@notmuchmail.org>;\r
+ Fri,  8 Jul 2016 03:13:34 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 42A2A6DE02B0\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 03:13:10 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [88.128.80.54])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 44271F993\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 06:13:09 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id C583421658; Fri,  8 Jul 2016 11:27:34 +0200 (CEST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v4 14/16] test indexing cleartext version of delivered\r
+ messages.\r
+Date: Fri,  8 Jul 2016 11:27:25 +0200\r
+Message-Id: <1467970047-8013-15-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 08 Jul 2016 10:13:41 -0000\r
+\r
+This requires a bit of reorganization:\r
+\r
+ * add_gnupg_home gets moved to test-lib.sh, and\r
+\r
+ * we allow passing --long-arguments to "notmuch new" via\r
+   emacs_fcc_message\r
+---\r
+ test/T350-crypto.sh           | 15 -------------\r
+ test/T357-index-decryption.sh | 49 +++++++++++++++++++++++++++++++++++++++++++\r
+ test/test-lib.sh              | 26 ++++++++++++++++++++++-\r
+ 3 files changed, 74 insertions(+), 16 deletions(-)\r
+ create mode 100755 test/T357-index-decryption.sh\r
+\r
+diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh\r
+index 4bc15bc..50cc526 100755\r
+--- a/test/T350-crypto.sh\r
++++ b/test/T350-crypto.sh\r
+@@ -7,21 +7,6 @@\r
+ test_description='PGP/MIME signature verification and decryption'\r
+ . ./test-lib.sh || exit 1\r
\r
+-add_gnupg_home ()\r
+-{\r
+-    local output\r
+-    [ -d ${GNUPGHOME} ] && return\r
+-    mkdir -m 0700 "$GNUPGHOME"\r
+-    $GPG --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
+-    test_debug "cat $GNUPGHOME/import.log"\r
+-    if ($GPG --quick-random --version >/dev/null 2>&1) ; then\r
+-      echo quick-random >> "$GNUPGHOME"/gpg.conf\r
+-    elif ($GPG --debug-quick-random --version >/dev/null 2>&1) ; then\r
+-      echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
+-    fi\r
+-    echo no-emit-version >> "$GNUPGHOME"/gpg.conf\r
+-}\r
+-\r
+ ##################################################\r
\r
+ add_gnupg_home\r
+diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh\r
+new file mode 100755\r
+index 0000000..27d6885\r
+--- /dev/null\r
++++ b/test/T357-index-decryption.sh\r
+@@ -0,0 +1,49 @@\r
++#!/usr/bin/env bash\r
++\r
++# TODO: test index-decryption-failed\r
++\r
++test_description='indexing decrypted mail'\r
++. ./test-lib.sh || exit 1\r
++\r
++##################################################\r
++\r
++add_gnupg_home\r
++# get key fingerprint\r
++FINGERPRINT=$($GPG --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)\r
++\r
++# create a test encrypted message\r
++test_expect_success 'emacs delivery of encrypted message' \\r
++'emacs_fcc_message \\r
++    "test encrypted message for cleartext index 001" \\r
++    "This is a test encrypted message with a wumpus.\n" \\r
++    "(mml-secure-message-encrypt)"'\r
++\r
++test_begin_subtest "search for unindexed cleartext"\r
++output=$(notmuch search wumpus)\r
++expected=''\r
++test_expect_equal \\r
++    "$output" \\r
++    "$expected"\r
++\r
++# create a test encrypted message that is indexed in the clear\r
++test_expect_success 'emacs delivery of encrypted message' \\r
++'emacs_fcc_message --try-decrypt \\r
++    "test encrypted message for cleartext index 002" \\r
++    "This is a test encrypted message with a wumpus.\n" \\r
++    "(mml-secure-message-encrypt)"'\r
++\r
++test_begin_subtest "emacs delivery of encrypted message, indexed cleartext"\r
++output=$(notmuch search wumpus)\r
++expected='thread:0000000000000002   2000-01-01 [1/1] Notmuch Test Suite; test encrypted message for cleartext index 002 (encrypted inbox)'\r
++test_expect_equal \\r
++    "$output" \\r
++    "$expected"\r
++\r
++# and the same search, but by property ($expected is untouched):\r
++test_begin_subtest "emacs search by property for one message"\r
++output=$(notmuch search has:index-decryption=success)\r
++test_expect_equal \\r
++    "$output" \\r
++    "$expected"\r
++\r
++test_done\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 5c14d1e..cb12ed9 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -93,6 +93,21 @@ else\r
+     GPG=gpg\r
+ fi\r
\r
++add_gnupg_home ()\r
++{\r
++    local output\r
++    [ -d ${GNUPGHOME} ] && return\r
++    mkdir -m 0700 "$GNUPGHOME"\r
++    $GPG --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
++    test_debug "cat $GNUPGHOME/import.log"\r
++    if ($GPG --quick-random --version >/dev/null 2>&1) ; then\r
++      echo quick-random >> "$GNUPGHOME"/gpg.conf\r
++    elif ($GPG --debug-quick-random --version >/dev/null 2>&1) ; then\r
++      echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
++    fi\r
++    echo no-emit-version >> "$GNUPGHOME"/gpg.conf\r
++}\r
++\r
+ # Convenience\r
+ #\r
+ # A regexp to match 5 and 40 hexdigits\r
+@@ -525,8 +540,17 @@ emacs_deliver_message ()\r
+ # Accepts arbitrary extra emacs/elisp functions to modify the message\r
+ # before sending, which is useful to doing things like attaching files\r
+ # to the message and encrypting/signing.\r
++#\r
++# If any GNU-style long-arguments (like --quiet or --try-decrypt) are\r
++# at the head of the argument list, they are sent directly to "notmuch\r
++# new" after message delivery\r
+ emacs_fcc_message ()\r
+ {\r
++    local nmn_args=''\r
++    while [[ "$1" =~ ^-- ]]; do\r
++        nmn_args="$nmn_args $1"\r
++        shift\r
++    done\r
+     local subject="$1"\r
+     local body="$2"\r
+     shift 2\r
+@@ -545,7 +569,7 @@ emacs_fcc_message ()\r
+          (insert \"${body}\")\r
+          $@\r
+          (notmuch-mua-send-and-exit))" || return 1\r
+-    notmuch new >/dev/null\r
++    notmuch new $nmn_args >/dev/null\r
+ }\r
\r
+ # Generate a corpus of email and add it to the database.\r
+-- \r
+2.8.1\r
+\r