Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 5b / 0d4076110a873cc924e7ec7c499165926c3367
1 Return-Path: <dkg@fifthhorseman.net>\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 arlo.cworth.org (Postfix) with ESMTP id 73FC66DE1BB7\r
6  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:31 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.023\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.023 tagged_above=-999 required=5\r
12  tests=[AWL=-0.023] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id TT8gZWaD4LDK for <notmuch@notmuchmail.org>;\r
16  Tue, 19 Jan 2016 18:53:29 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id C33966DE1770\r
19  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:16 -0800 (PST)\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id 5F606F99E\r
22  for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:14 -0500 (EST)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id 0C87C20956; Tue, 19 Jan 2016 18:53:11 -0800 (PST)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH v2 14/16] test indexing cleartext version of delivered\r
28  messages.\r
29 Date: Tue, 19 Jan 2016 21:52:47 -0500\r
30 Message-Id: <1453258369-7366-15-git-send-email-dkg@fifthhorseman.net>\r
31 X-Mailer: git-send-email 2.7.0.rc3\r
32 In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
33 References: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Wed, 20 Jan 2016 02:53:31 -0000\r
47 \r
48 This requires a bit of reorganization:\r
49 \r
50  * add_gnupg_home gets moved to test-lib.sh, and\r
51 \r
52  * we allow passing --long-arguments to "notmuch new" via\r
53    emacs_fcc_message\r
54 ---\r
55  test/T350-crypto.sh           | 15 ---------------\r
56  test/T355-index-decryption.sh | 42 ++++++++++++++++++++++++++++++++++++++++++\r
57  test/test-lib.sh              | 26 +++++++++++++++++++++++++-\r
58  3 files changed, 67 insertions(+), 16 deletions(-)\r
59  create mode 100755 test/T355-index-decryption.sh\r
60 \r
61 diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh\r
62 index 4bc15bc..50cc526 100755\r
63 --- a/test/T350-crypto.sh\r
64 +++ b/test/T350-crypto.sh\r
65 @@ -7,21 +7,6 @@\r
66  test_description='PGP/MIME signature verification and decryption'\r
67  . ./test-lib.sh || exit 1\r
68  \r
69 -add_gnupg_home ()\r
70 -{\r
71 -    local output\r
72 -    [ -d ${GNUPGHOME} ] && return\r
73 -    mkdir -m 0700 "$GNUPGHOME"\r
74 -    $GPG --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
75 -    test_debug "cat $GNUPGHOME/import.log"\r
76 -    if ($GPG --quick-random --version >/dev/null 2>&1) ; then\r
77 -       echo quick-random >> "$GNUPGHOME"/gpg.conf\r
78 -    elif ($GPG --debug-quick-random --version >/dev/null 2>&1) ; then\r
79 -       echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
80 -    fi\r
81 -    echo no-emit-version >> "$GNUPGHOME"/gpg.conf\r
82 -}\r
83 -\r
84  ##################################################\r
85  \r
86  add_gnupg_home\r
87 diff --git a/test/T355-index-decryption.sh b/test/T355-index-decryption.sh\r
88 new file mode 100755\r
89 index 0000000..03e49cc\r
90 --- /dev/null\r
91 +++ b/test/T355-index-decryption.sh\r
92 @@ -0,0 +1,42 @@\r
93 +#!/usr/bin/env bash\r
94 +\r
95 +# TODO: test index-decryption-failed\r
96 +\r
97 +test_description='indexing decrypted mail'\r
98 +. ./test-lib.sh || exit 1\r
99 +\r
100 +##################################################\r
101 +\r
102 +add_gnupg_home\r
103 +# get key fingerprint\r
104 +FINGERPRINT=$($GPG --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)\r
105 +\r
106 +# create a test encrypted message\r
107 +test_expect_success 'emacs delivery of encrypted message' \\r
108 +'emacs_fcc_message \\r
109 +    "test encrypted message for cleartext index 001" \\r
110 +    "This is a test encrypted message with a wumpus.\n" \\r
111 +    "(mml-secure-message-encrypt)"'\r
112 +\r
113 +test_begin_subtest "search for unindexed cleartext"\r
114 +output=$(notmuch search wumpus)\r
115 +expected=''\r
116 +test_expect_equal \\r
117 +    "$output" \\r
118 +    "$expected"\r
119 +\r
120 +# create a test encrypted message that is indexed in the clear\r
121 +test_expect_success 'emacs delivery of encrypted message' \\r
122 +'emacs_fcc_message --try-decrypt \\r
123 +    "test encrypted message for cleartext index 002" \\r
124 +    "This is a test encrypted message with a wumpus.\n" \\r
125 +    "(mml-secure-message-encrypt)"'\r
126 +\r
127 +test_begin_subtest "emacs delivery of encrypted message, indexed cleartext"\r
128 +output=$(notmuch search wumpus)\r
129 +expected='thread:0000000000000002   2000-01-01 [1/1] Notmuch Test Suite; test encrypted message for cleartext index 002 (encrypted inbox index-decrypted)'\r
130 +test_expect_equal \\r
131 +    "$output" \\r
132 +    "$expected"\r
133 +\r
134 +test_done\r
135 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
136 index 878b98b..1582006 100644\r
137 --- a/test/test-lib.sh\r
138 +++ b/test/test-lib.sh\r
139 @@ -92,6 +92,21 @@ else\r
140      GPG=gpg\r
141  fi\r
142  \r
143 +add_gnupg_home ()\r
144 +{\r
145 +    local output\r
146 +    [ -d ${GNUPGHOME} ] && return\r
147 +    mkdir -m 0700 "$GNUPGHOME"\r
148 +    $GPG --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
149 +    test_debug "cat $GNUPGHOME/import.log"\r
150 +    if ($GPG --quick-random --version >/dev/null 2>&1) ; then\r
151 +       echo quick-random >> "$GNUPGHOME"/gpg.conf\r
152 +    elif ($GPG --debug-quick-random --version >/dev/null 2>&1) ; then\r
153 +       echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
154 +    fi\r
155 +    echo no-emit-version >> "$GNUPGHOME"/gpg.conf\r
156 +}\r
157 +\r
158  # Convenience\r
159  #\r
160  # A regexp to match 5 and 40 hexdigits\r
161 @@ -514,8 +529,17 @@ emacs_deliver_message ()\r
162  # Accepts arbitrary extra emacs/elisp functions to modify the message\r
163  # before sending, which is useful to doing things like attaching files\r
164  # to the message and encrypting/signing.\r
165 +#\r
166 +# If any GNU-style long-arguments (like --quiet or --try-decrypt) are\r
167 +# at the head of the argument list, they are sent directly to "notmuch\r
168 +# new" after message delivery\r
169  emacs_fcc_message ()\r
170  {\r
171 +    local nmn_args=''\r
172 +    while [[ "$1" =~ ^-- ]]; do\r
173 +        nmn_args="$nmn_args $1"\r
174 +        shift\r
175 +    done\r
176      local subject="$1"\r
177      local body="$2"\r
178      shift 2\r
179 @@ -534,7 +558,7 @@ emacs_fcc_message ()\r
180            (insert \"${body}\")\r
181            $@\r
182            (notmuch-mua-send-and-exit))" || return 1\r
183 -    notmuch new >/dev/null\r
184 +    notmuch new $nmn_args >/dev/null\r
185  }\r
186  \r
187  # Generate a corpus of email and add it to the database.\r
188 -- \r
189 2.7.0.rc3\r
190 \r