Re: [PATCH] travis: use ppa:notmuch/notmuch

2019-05-06 Thread David Bremner
Daniel Kahn Gillmor  writes:

> On Sun 2019-05-05 19:48:47 -0300, David Bremner wrote:
>> Daniel Kahn Gillmor  writes:
>>> This should allow us to continue to use the Travis continuous
>>> integration build on the release branch.
>>
>> And on master as well, I guess.
>
> yes, it should work on both master and release.  Please let me know if
> it doesn't.

Seems to be good now with the updated PPA; pushed to master. I didn't
apply it to release yet at as that is currently buildable with
gmime-2.6. I guess it depends on how long before release again, whether
we should also switch the release branch to gmime-3.0 and the new PPA.

d


___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] travis: use ppa:notmuch/notmuch

2019-05-06 Thread Daniel Kahn Gillmor
On Sun 2019-05-05 19:48:47 -0300, David Bremner wrote:
> Daniel Kahn Gillmor  writes:
>> This should allow us to continue to use the Travis continuous
>> integration build on the release branch.
>
> And on master as well, I guess.

yes, it should work on both master and release.  Please let me know if
it doesn't.

> Apropos CI, I'm continuing to look at gitlab CI. I'm currently blocked
> by what seems to be a bad interaction between emacs and docker [1].
>
> [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=+35557

yuck.  i'm afraid i can't help much there.

   --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: parallelize test suite

2019-05-06 Thread Daniel Kahn Gillmor
On Sun 2019-05-05 19:44:01 +0300, Tomi Ollila wrote:
>> I actually think that CI and autobuilders *should* exercise the parallel
>> tests, as annoying as that might be initially, because it seems likely
>> to catch any other potential entanglements.
>
> ... after it has been proven a bit more to work...

i tend to think the other way around -- the way to prove it is to push
it into the CI pipelines on the development branch, rather than trying
to prove it on individual developer systems.

> One thing more, the "perverse" pre-caching done in add_email_corpus
> can be retained -- just do that step *before* going to parallelism...

You could do that, but i'm not sure how much you'd gain from it -- its
current implementation is all mixed up with the parallelized tests,
anyway.  If you wanted to propose a concrete re-optimization like this,
i'd be happy to review it, test it and report back on the speedup
gained.

thanks for thinking this through, Tomi!

 --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: decryption error for signed+encrypted messages

2019-05-06 Thread Daniel Kahn Gillmor
blast from the past (cleaning up the bugtracker a bit).

On Thu 2014-01-23 09:37:47 -0400, David Bremner wrote:
> This bug seems to be (some time ago) marked fixed upstream
>
>  https://bugzilla.gnome.org/show_bug.cgi?id=677088

This was definitely a bug in gmime, and it was resolved by gmime moving
entirely to gpgme.  I've cleared the notmuch::moreinfo tag on this
report and added notmuch::fixed (even though it was not notmuch which
did the fixing.

--dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: add configurable port to smtp-dummy

2019-05-06 Thread Daniel Kahn Gillmor
On Mon 2019-05-06 22:39:26 +0300, Tomi Ollila wrote:
> we run smtp-dummy as:
>
>smtp_dummy_pid=
>eval `$TEST_DIRECTORY/smtp-dummy --background sent_message`
>
> if process binds using port `0` system fill find available port for it...
>
> ... which smtp-dummy could return in a variable to be evaluated ...
>
> ... and that could replace all this what has been done here ...

i agree with Tomi that something like this (smtp-dummy asks for an
available port and reports it), is the ideal solution, in that it means
that two copies of the notmuch testsuite itself could even run
independently and avoid contending for system resources.

but i think Bremner's manually-set port is a completely reasonable first
step, and we can adopt the proposed optimization later.  LGTM.

  --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] tests: environment variable to specify that tests should be serialized

2019-05-06 Thread Daniel Kahn Gillmor
On Mon 2019-05-06 22:15:49 +0300, Tomi Ollila wrote:
> While I like this parallelization option, and hope a version (could be even 
> David's smtp_dummy change) of it could be available in notmuch repository
> as soon as possible, I would not like it being default -- just like make -J
> is not default...
>
> ... it being default, unsuspicious user running `make test` might have his
> multitasking maching eating too much resources for a particular purpose and
> slowing everything else. 

if we're voting, i vote in favor of parallel defaults wherever possible,
with a way to force serialization.  I'd much rather have my machine
finish the thing i just asked it to do in less time by default, than
wait around twiddling my thumbs while the machine has spare cycles.  The
context switch for my mind is way more expensive than the context
switches going on within the computer.

The change from 2 minutes to < 30 seconds is a game-changer in terms of
keeping me focused while i'm developing.  make it easy to do that!

--dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] configure: Ensure that GMime can extract session keys

2019-05-06 Thread Daniel Kahn Gillmor
On Mon 2019-05-06 16:16:55 -0400, Daniel Kahn Gillmor wrote:
> GMime 3.0 and higher can extract session keys, but it will *not*
> extract session keys if it was built with --disable-crypto, or if it
> was built against GPGME version < 1.8.0.
>
> Notmuch currently expects to be able to extract session keys, and
> tests will fail if it is not possible, so we ensure that this is the
> case during ./configure time.

please consider v2 of this -- my initial sent draft only worked by
accident due to a malingering GnuPG homedir, bc i'd forgotten to set
GNUPGHOME in this line:

> +   && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \

v2 handles it just fine, sorry for the noise.

   --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] configure: Ensure that GMime can extract session keys

2019-05-06 Thread Daniel Kahn Gillmor
GMime 3.0 and higher can extract session keys, but it will *not*
extract session keys if it was built with --disable-crypto, or if it
was built against GPGME version < 1.8.0.

Notmuch currently expects to be able to extract session keys, and
tests will fail if it is not possible, so we ensure that this is the
case during ./configure time.

Part of this feels awkward because notmuch doesn't directly depend on
gpg at all.  Rather, it depends on GMime, and the current
implementation of GMime depends on GPGME for its crypto, and GPGME in
turn depends on gpg.

So the use of gpg in ./configure isn't actually introducing a new
dependency, though if a future version of GMime were ever to move away
from GnuPG, we might need to reconsider.

Note that this changeset depends on
id:20190506174327.13457-1-...@fifthhorseman.net , which supplies the
rfc822 message test/corpora/crypto/basic-encrypted.eml used in it.

Signed-off-by: Daniel Kahn Gillmor 
---
 configure | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/configure b/configure
index 9140026a..e157aadf 100755
--- a/configure
+++ b/configure
@@ -497,6 +497,60 @@ if pkg-config --exists "gmime-3.0 > $GMIME_MINVER"; then
 have_gmime=1
 gmime_cflags=$(pkg-config --cflags gmime-3.0)
 gmime_ldflags=$(pkg-config --libs gmime-3.0)
+
+printf "Checking for GMime session key extraction support... "
+
+cat > _check_session_keys.c <
+#include 
+
+int main () {
+GError *error = NULL;
+GMimeParser *parser = NULL;
+GMimeMultipartEncrypted *body = NULL;
+GMimeDecryptResult *decrypt_result = NULL;
+GMimeObject *output = NULL;
+
+g_mime_init ();
+parser = g_mime_parser_new ();
+g_mime_parser_init_with_stream (parser, 
g_mime_stream_file_open("test/corpora/crypto/basic-encrypted.eml", "r", 
));
+if (error) return !! fprintf (stderr, "failed to instantiate parser with 
test/corpora/crypto/basic-encrypted.eml\n");
+
+body = GMIME_MULTIPART_ENCRYPTED(g_mime_message_get_mime_part 
(g_mime_parser_construct_message (parser, NULL)));
+if (body == NULL) return !!fprintf (stderr, "did not find a 
multipart encrypted message\n");
+
+output = g_mime_multipart_encrypted_decrypt (body, 
GMIME_DECRYPT_EXPORT_SESSION_KEY, NULL, _result, );
+if (error || output == NULL) return !! fprintf (stderr, "decryption 
failed\n");
+
+if (decrypt_result == NULL) return !! fprintf (stderr, "no 
GMimeDecryptResult found\n");
+if (decrypt_result->session_key == NULL) return !! fprintf (stderr, 
"GMimeDecryptResult has no session key\n");
+
+printf ("%s\n", decrypt_result->session_key);
+return 0;
+}
+EOF
+if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags}  _check_session_keys.c 
-o _check_session_keys > /dev/null 2>&1 \
+   && TEMP_GPG=$(mktemp -d) \
+   && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < 
test/gnupg-secret-key.asc \
+   && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
+   && [ $SESSION_KEY = 
9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
+then
+printf "OK.\n"
+else
+cat 

[PATCH] util/crypto: improve comment

2019-05-06 Thread Daniel Kahn Gillmor
The comment line here lingers from when we were using some fancy
version checking about session keys.  Correct it to match the current
state.

Signed-off-by: Daniel Kahn Gillmor 
---
 util/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/crypto.c b/util/crypto.c
index ba67d4f4..99104e78 100644
--- a/util/crypto.c
+++ b/util/crypto.c
@@ -40,7 +40,7 @@ _notmuch_crypto_decrypt (bool *attempted,
 if (decrypt == NOTMUCH_DECRYPT_FALSE)
return NULL;
 
-/* the versions of notmuch that can support session key decryption */
+/* try decryption with session key if one is stashed */
 if (message) {
notmuch_message_properties_t *list = NULL;
 
-- 
2.20.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] configure: Ensure that GMime can extract session keys

2019-05-06 Thread Daniel Kahn Gillmor
GMime 3.0 and higher can extract session keys, but it will *not*
extract session keys if it was built with --disable-crypto, or if it
was built against GPGME version < 1.8.0.

Notmuch currently expects to be able to extract session keys, and
tests will fail if it is not possible, so we ensure that this is the
case during ./configure time.

Part of this feels awkward because notmuch doesn't directly depend on
gpg at all.  Rather, it depends on GMime, and the current
implementation of GMime depends on GPGME for its crypto, and GPGME in
turn depends on gpg.

So the use of gpg in ./configure isn't actually introducing a new
dependency, though if a future version of GMime were ever to move away
from GnuPG, we might need to reconsider.

Note that this changeset depends on
id:20190506174327.13457-1-...@fifthhorseman.net , which supplies the
rfc822 message test/corpora/crypto/basic-encrypted.eml used in it.

Signed-off-by: Daniel Kahn Gillmor 
---
 configure | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/configure b/configure
index 9140026a..805292be 100755
--- a/configure
+++ b/configure
@@ -497,6 +497,60 @@ if pkg-config --exists "gmime-3.0 > $GMIME_MINVER"; then
 have_gmime=1
 gmime_cflags=$(pkg-config --cflags gmime-3.0)
 gmime_ldflags=$(pkg-config --libs gmime-3.0)
+
+printf "Checking for GMime session key extraction support... "
+
+cat > _check_session_keys.c <
+#include 
+
+int main () {
+GError *error = NULL;
+GMimeParser *parser = NULL;
+GMimeMultipartEncrypted *body = NULL;
+GMimeDecryptResult *decrypt_result = NULL;
+GMimeObject *output = NULL;
+
+g_mime_init ();
+parser = g_mime_parser_new ();
+g_mime_parser_init_with_stream (parser, 
g_mime_stream_file_open("test/corpora/crypto/basic-encrypted.eml", "r", 
));
+if (error) return !! fprintf (stderr, "failed to instantiate parser with 
test/corpora/crypto/basic-encrypted.eml\n");
+
+body = GMIME_MULTIPART_ENCRYPTED(g_mime_message_get_mime_part 
(g_mime_parser_construct_message (parser, NULL)));
+if (body == NULL) return !!fprintf (stderr, "did not find a 
multipart encrypted message\n");
+
+output = g_mime_multipart_encrypted_decrypt (body, 
GMIME_DECRYPT_EXPORT_SESSION_KEY, NULL, _result, );
+if (error || output == NULL) return !! fprintf (stderr, "decryption 
failed\n");
+
+if (decrypt_result == NULL) return !! fprintf (stderr, "no 
GMimeDecryptResult found\n");
+if (decrypt_result->session_key == NULL) return !! fprintf (stderr, 
"GMimeDecryptResult has no session key\n");
+
+printf ("%s\n", decrypt_result->session_key);
+return 0;
+}
+EOF
+if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags}  _check_session_keys.c 
-o _check_session_keys > /dev/null 2>&1 \
+   && TEMP_GPG=$(mktemp -d) \
+   && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < 
test/gnupg-secret-key.asc \
+   && SESSION_KEY=$(./_check_session_keys) \
+   && [ $SESSION_KEY = 
9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
+then
+printf "OK.\n"
+else
+cat 

Re: [PATCH] test: add configurable port to smtp-dummy

2019-05-06 Thread Tomi Ollila
On Mon, May 06 2019, David Bremner wrote:

> This is to allow smtp-dummy to potentially be used from multiple T*.sh
> without collisions during parallel test running.
> ---
>  test/T310-emacs.sh | 3 +++
>  test/smtp-dummy.c  | 7 ++-
>  test/test-lib.sh   | 4 +++-
>  3 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
> index c06a8133..3eab1ba9 100755
> --- a/test/T310-emacs.sh
> +++ b/test/T310-emacs.sh
> @@ -5,6 +5,9 @@ test_description="emacs interface"
>  
>  EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
>  
> +# this port must be unique to each test script using smtp-dummy
> +export SMTP_DUMMY_PORT=25125

I suggest 25310 ! :D

(
SMTP_DUMMY_PORT=${0%%-*}
SMTP_DUMMY_PORT=$(( 25000 + ${SMTP_DUMMY_PORT#?} ))

is probably too complicated and error prone ;)

> +
>  add_email_corpus
>  
>  # syntax errors in test-lib.el cause mysterious failures
> diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
> index 71992edd..4cd66f5c 100644
> --- a/test/smtp-dummy.c
> +++ b/test/smtp-dummy.c
> @@ -120,6 +120,7 @@ int
>  main (int argc, char *argv[])
>  {
>  const char *progname;
> +const char *port_str;
>  char *output_filename;
>  FILE *peer_file = NULL, *output = NULL;
>  int sock = -1, peer, err;
> @@ -191,7 +192,11 @@ main (int argc, char *argv[])
>  
>  memset (, 0, sizeof (addr));
>  addr.sin_family = AF_INET;
> -addr.sin_port = htons (25025);
> +if ((port_str = getenv ("SMTP_DUMMY_PORT")))

If we required SMTP_DUMMY_PORT to be defined in environmment (and not
fallback to 25025 if not) we'd have less change to forget defining
it... but that may be too much to ask... ;/

... continuing on same subject below ...

> + addr.sin_port = htons (atoi (port_str));
> +else
> + addr.sin_port = htons (25025);
> +
>  addr.sin_addr = *(struct in_addr *) hostinfo->h_addr;
>  err = bind (sock, (struct sockaddr *) , sizeof (addr));
>  if (err) {
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 43339902..f3be537b 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -93,6 +93,8 @@ TEST_GDB=${TEST_GDB:-gdb}
>  TEST_CC=${TEST_CC:-cc}
>  TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
>  
> +SMTP_DUMMY_PORT=${SMTP_DUMMY_PORT:-25025}

... in that case this would not be set here ( but since we don't have 
`set -u` set in our test env (I have some half-decade-old patches for that
laying around though) we'd have to check that in emacs_deliver_message)

well, perhaps chance having same port is very low, in 10 years there has
been only one file running using that...

... but now I remember something (else) I though doing half-decade ago:

we run smtp-dummy as:

   smtp_dummy_pid=
   eval `$TEST_DIRECTORY/smtp-dummy --background sent_message`

if process binds using port `0` system fill find available port for it...

... which smtp-dummy could return in a variable to be evaluated ...

... and that could replace all this what has been done here ...


but whatever -- and IMO we could have parallelization w/o this already
not *IF* it is not done by default (or even default but then someone(tm)
has to fix this some way in near future (I'd vote smtp-dummy choosing 
port :D, that cannot be too hard.


Tomi


> +
>  # Protect ourselves from common misconfiguration to export
>  # CDPATH into the environment
>  unset CDPATH
> @@ -324,7 +326,7 @@ emacs_deliver_message ()
>   "(let ((message-send-mail-function 'message-smtpmail-send-it)
> (mail-host-address \"example.com\")
>  (smtpmail-smtp-server \"localhost\")
> -(smtpmail-smtp-service \"25025\"))
> +(smtpmail-smtp-service \"${SMTP_DUMMY_PORT}\"))
>  (notmuch-mua-mail)
>  (message-goto-to)
>  (insert \"test_su...@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 
> -\")
> -- 
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] tests: environment variable to specify that tests should be serialized

2019-05-06 Thread Tomi Ollila
On Mon, May 06 2019, Jameson Rollins wrote:

> From: Jameson Graef Rollins 
>
> If NOTMUCH_TEST_SERIALIZE is non-null all tests will be run in series,
> rather than in parallel.

While I like this parallelization option, and hope a version (could be even 
David's smtp_dummy change) of it could be available in notmuch repository
as soon as possible, I would not like it being default -- just like make -J
is not default...

... it being default, unsuspicious user running `make test` might have his
multitasking maching eating too much resources for a particular purpose and
slowing everything else. 

The simplest way to invoke parallelized tests could be make test-parallel
and/or make test p=1 ...or NOTMUCH_TEST_PARALLELIZE make test.

That's my opinion written out loud... vote me over if disagreed.. :D

Tomi

> ---
>  test/README   | 8 ++--
>  test/notmuch-test | 2 +-
>  2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/test/README b/test/README
> index b378c3ff..3f54af58 100644
> --- a/test/README
> +++ b/test/README
> @@ -43,7 +43,6 @@ these system tools. Most often the tests are written, 
> reviewed and
>  tested on Linux system so such portability issues arise from time to
>  time.
>  
> -
>  Running Tests
>  -
>  The easiest way to run tests is to say "make test", (or simply run the
> @@ -105,9 +104,14 @@ to with emacs, e.g.
>  
>   make test TEST_CC=gcc TEST_CFLAGS="-g -O2"
>  
> +Parallel Execution
> +--
> +If either the moreutils or GNU "parallel" utility is available all
> +tests will be run in parallel.  If the NOTMUCH_TEST_SERIALIZE variable
> +is non-null all tests will be executed sequentially.
> +
>  Quiet Execution
>  ---
> -
>  Normally, when new script starts and when test PASSes you get a message
>  printed on screen. This printing can be disabled by setting the
>  NOTMUCH_TEST_QUIET variable to a non-null value. Message on test
> diff --git a/test/notmuch-test b/test/notmuch-test
> index a4b7a1eb..bd3e080a 100755
> --- a/test/notmuch-test
> +++ b/test/notmuch-test
> @@ -40,7 +40,7 @@ fi
>  
>  trap 'e=$?; kill $!; exit $e' HUP INT TERM
>  # Run the tests
> -if command -v parallel >/dev/null ; then
> +if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then
>  if parallel -h | grep -q GNU ; then
>  echo "INFO: running tests with GNU parallel"
>  printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
> -- 
> 2.20.1
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 1/3] emacs: test notmuch-show during message decryption

2019-05-06 Thread Daniel Kahn Gillmor
We did not have a test showing what message decryption looks like
within notmuch-emacs.  This change gives us a baseline for future work
on the notmuch-emacs interface.

This differs from previous revisions of this patch in that it should
be insensitive to the order in which the local filesystem readdir()s
the underlying maildir.

Signed-off-by: Daniel Kahn Gillmor 
---
 test/T357-index-decryption.sh | 13 +
 test/T450-emacs-show.sh   | 15 ++
 test/corpora/crypto/basic-encrypted.eml   | 28 +++
 .../notmuch-show-decrypted-message| 11 
 .../notmuch-show-undecryptable-message| 10 +++
 5 files changed, 71 insertions(+), 6 deletions(-)
 create mode 100644 test/corpora/crypto/basic-encrypted.eml
 create mode 100644 
test/emacs-show.expected-output/notmuch-show-decrypted-message
 create mode 100644 
test/emacs-show.expected-output/notmuch-show-undecryptable-message

diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh
index 0a602e50..c9cd5e30 100755
--- a/test/T357-index-decryption.sh
+++ b/test/T357-index-decryption.sh
@@ -224,10 +224,11 @@ add_email_corpus crypto
 
 test_begin_subtest "indexing message fails when secret key not available"
 notmuch reindex --decrypt=true id:simple-encryp...@crypto.notmuchmail.org
-output=$(notmuch dump )
-expected='#notmuch-dump batch-tag:3 config,properties,tags
-+encrypted +inbox +unread -- id:simple-encryp...@crypto.notmuchmail.org
-#= simple-encryp...@crypto.notmuchmail.org index.decryption=failure'
+output=$(notmuch dump | LC_ALL=C sort)
+expected='#= simple-encryp...@crypto.notmuchmail.org index.decryption=failure
+#notmuch-dump batch-tag:3 config,properties,tags
++encrypted +inbox +unread -- id:basic-encryp...@crypto.notmuchmail.org
++encrypted +inbox +unread -- id:simple-encryp...@crypto.notmuchmail.org'
 test_expect_equal \
 "$output" \
 "$expected"
@@ -245,8 +246,8 @@ notmuch restore <"
 
+
+# switching to the crypto corpus, using gpg from here on:
+add_gnupg_home
+add_email_corpus crypto
+
+test_begin_subtest "show decrypted message"
+test_emacs '(notmuch-show "id:basic-encryp...@crypto.notmuchmail.org")
+(test-visible-output)'
+test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT
+
+test_begin_subtest "show undecryptable message"
+test_emacs '(notmuch-show "id:simple-encryp...@crypto.notmuchmail.org")
+(test-visible-output)'
+test_expect_equal_file $EXPECTED/notmuch-show-undecryptable-message OUTPUT
+
 test_done
diff --git a/test/corpora/crypto/basic-encrypted.eml 
b/test/corpora/crypto/basic-encrypted.eml
new file mode 100644
index ..1ba4698a
--- /dev/null
+++ b/test/corpora/crypto/basic-encrypted.eml
@@ -0,0 +1,28 @@
+From: test_su...@notmuchmail.org
+To: test_su...@notmuchmail.org
+Subject: Here is the password
+Date: Sat, 01 Jan 2000 12:00:00 +
+Message-ID: 
+MIME-Version: 1.0
+Content-Type: multipart/encrypted; boundary="=-=-=";
+   protocol="application/pgp-encrypted"
+
+--=-=-=
+Content-Type: application/pgp-encrypted
+
+Version: 1
+
+--=-=-=
+Content-Type: application/octet-stream
+
+-BEGIN PGP MESSAGE-
+
+hIwDxE023q1UqxYBBACp70e7KPy9OYaheIrkLzmhq1lRqmy51aL1jBL0K/qN7rfK
+BZEG1cR8jeLjTFdPKPLVKJI80r7FgKI0ywvWvl6R1aE1Ty5BnVXT9XzCrEH7fqCl
+SKK82EvolXTohAZHUrh6K66eQQTTIAC1n7B0A8hErzkgaM4+seN3LlvezT6TLNKM
+ATpqsEbM2MVrGgw0b3oUsGGAPEt2MmjNEYsriKnqwt6dJDZc//XyhjgMQayiD8da
+N1gT3oqgu/gKCpBZDYzHf9OtVi2UnlFDWy6rrMZLjWDnIv4ve9Pn/qolwHVjzdJ1
+ZfjNC5t0z3XADKGrjN9wutr4qm7STW1rHAXHP68TQTxI0qgJKjPXNKWEw6g=
+=pJG4
+-END PGP MESSAGE-
+--=-=-=--
diff --git a/test/emacs-show.expected-output/notmuch-show-decrypted-message 
b/test/emacs-show.expected-output/notmuch-show-decrypted-message
new file mode 100644
index ..08a9e4f6
--- /dev/null
+++ b/test/emacs-show.expected-output/notmuch-show-decrypted-message
@@ -0,0 +1,11 @@
+test_su...@notmuchmail.org (2000-01-01) (encrypted inbox)
+Subject: Here is the password
+To: test_su...@notmuchmail.org
+Date: Sat, 01 Jan 2000 12:00:00 +
+
+[ multipart/encrypted ]
+[ Decryption successful ]
+[ Unknown signature status ]
+[ application/pgp-encrypted ]
+[ text/plain ]
+The password is "abcd1234!", please do not tell anyone.
diff --git a/test/emacs-show.expected-output/notmuch-show-undecryptable-message 
b/test/emacs-show.expected-output/notmuch-show-undecryptable-message
new file mode 100644
index ..530ff286
--- /dev/null
+++ b/test/emacs-show.expected-output/notmuch-show-undecryptable-message
@@ -0,0 +1,10 @@
+Daniel Kahn Gillmor  (2016-12-22) (encrypted inbox)
+Subject: encrypted message
+To: d...@fifthhorseman.net
+Date: Thu, 22 Dec 2016 08:34:56 -0400
+
+[ multipart/encrypted ]
+[ Decryption error ]
+[ Unknown signature status ]
+[ application/pgp-encrypted ]
+[ application/octet-stream ]
-- 
2.20.1

___
notmuch mailing list
notmuch@notmuchmail.org

Re: [PATCH v2 1/3] emacs: test notmuch-show during message decryption

2019-05-06 Thread Daniel Kahn Gillmor
On Fri 2019-05-03 17:59:49 +, David Bremner wrote:
> Daniel Kahn Gillmor  writes:
>
>> We did not have a test showing what message decryption looks like
>> within notmuch-emacs.  This change gives us a baseline for future work
>> on the notmuch-emacs interface.
>> ---
>>
>> The difference between this and the prior version of the patch is that
>> it updates T357-index-decryption.sh as well, to ensure all tests pass.
>>
>
> I don't _think_ this is gmime3 related, but I get
>
> T357-index-decryption: Testing indexing decrypted mail
>  FAIL   indexing message fails when secret key not available
>   --- T357-index-decryption.31.expected   2019-05-03 17:57:26.701988487 
> +
>   +++ T357-index-decryption.31.output 2019-05-03 17:57:26.701988487 
> +
>   @@ -1,4 +1,4 @@
>#notmuch-dump batch-tag:3 config,properties,tags
>   ++encrypted +inbox +unread -- id:basic-encryp...@crypto.notmuchmail.org
>+encrypted +inbox +unread -- id:simple-encryp...@crypto.notmuchmail.org
>#= simple-encryp...@crypto.notmuchmail.org index.decryption=failure
>   -+encrypted +inbox +unread -- id:basic-encryp...@crypto.notmuchmail.org
>  FAIL   cleartext index recovery on reindexing with stashed session keys
>   --- T357-index-decryption.33.expected   2019-05-03 17:57:26.817988197 
> +
>   +++ T357-index-decryption.33.output 2019-05-03 17:57:26.817988197 
> +
>   @@ -1 +1 @@
>   -thread:0001   2016-12-22 [1/1] Daniel Kahn Gillmor; 
> encrypted message (encrypted inbox unread)
>   +thread:0002   2016-12-22 [1/1] Daniel Kahn Gillmor; 
> encrypted message (encrypted inbox unread)
>
> Applying on top of 103c11822


hm, right, thanks.  The issue here is likely that your filesystem's
readdir puts the messages in the corpus in a different order than mine
does.So these failures are due only to the order in which "notmuch
new" encounters the messages in corpus/crypto.

I'll send a revised patch that should be ordering-independent.  thanks
for catching this!

--dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: add configurable port to smtp-dummy

2019-05-06 Thread David Bremner
This is to allow smtp-dummy to potentially be used from multiple T*.sh
without collisions during parallel test running.
---
 test/T310-emacs.sh | 3 +++
 test/smtp-dummy.c  | 7 ++-
 test/test-lib.sh   | 4 +++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index c06a8133..3eab1ba9 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -5,6 +5,9 @@ test_description="emacs interface"
 
 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
 
+# this port must be unique to each test script using smtp-dummy
+export SMTP_DUMMY_PORT=25125
+
 add_email_corpus
 
 # syntax errors in test-lib.el cause mysterious failures
diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
index 71992edd..4cd66f5c 100644
--- a/test/smtp-dummy.c
+++ b/test/smtp-dummy.c
@@ -120,6 +120,7 @@ int
 main (int argc, char *argv[])
 {
 const char *progname;
+const char *port_str;
 char *output_filename;
 FILE *peer_file = NULL, *output = NULL;
 int sock = -1, peer, err;
@@ -191,7 +192,11 @@ main (int argc, char *argv[])
 
 memset (, 0, sizeof (addr));
 addr.sin_family = AF_INET;
-addr.sin_port = htons (25025);
+if ((port_str = getenv ("SMTP_DUMMY_PORT")))
+   addr.sin_port = htons (atoi (port_str));
+else
+   addr.sin_port = htons (25025);
+
 addr.sin_addr = *(struct in_addr *) hostinfo->h_addr;
 err = bind (sock, (struct sockaddr *) , sizeof (addr));
 if (err) {
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 43339902..f3be537b 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -93,6 +93,8 @@ TEST_GDB=${TEST_GDB:-gdb}
 TEST_CC=${TEST_CC:-cc}
 TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
 
+SMTP_DUMMY_PORT=${SMTP_DUMMY_PORT:-25025}
+
 # Protect ourselves from common misconfiguration to export
 # CDPATH into the environment
 unset CDPATH
@@ -324,7 +326,7 @@ emacs_deliver_message ()
"(let ((message-send-mail-function 'message-smtpmail-send-it)
(mail-host-address \"example.com\")
   (smtpmail-smtp-server \"localhost\")
-  (smtpmail-smtp-service \"25025\"))
+  (smtpmail-smtp-service \"${SMTP_DUMMY_PORT}\"))
   (notmuch-mua-mail)
   (message-goto-to)
   (insert \"test_su...@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 
-\")
-- 
2.20.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch