unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob b296a9c59f5a422df6e23e603db060021412f193 4168 bytes (raw)
name: test/T358-emacs-protected-headers.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
#!/usr/bin/env bash

test_description="protected headers in emacs interface"
. $(dirname "$0")/test-lib.sh || exit 1
. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1

# testing protected headers with emacs
test_require_emacs
add_gnupg_home
add_email_corpus protected-headers

test_begin_subtest "notmuch-search should show not unindexed protected subject header in emacs"
test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
	    (notmuch-test-wait)
	    (test-output)'
cat <<EOF >EXPECTED
  2000-01-01 [1/1]   test_suite@notmuchmail.org  Subject Unavailable (encrypted inbox unread)
End of search results.
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "notmuch-show should not show unindexed protected subject header in emacs when nm-c-process-mime is nil"
test_emacs '(let ((notmuch-crypto-process-mime nil))
             (notmuch-show "id:protected-header@crypto.notmuchmail.org")
             (test-output))'
cat <<EOF >EXPECTED
test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
Subject: Subject Unavailable
To: test_suite@notmuchmail.org
Date: Sat, 01 Jan 2000 12:00:00 +0000

[ multipart/encrypted ]
[ Unknown encryption status ]
[ application/pgp-encrypted ]
[ application/octet-stream ]
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "notmuch-show should show protected subject header in emacs"
test_emacs '(notmuch-show "id:protected-header@crypto.notmuchmail.org")
	    (test-output)'
cat <<EOF >EXPECTED
test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
Subject: This is a protected header
To: test_suite@notmuchmail.org
Date: Sat, 01 Jan 2000 12:00:00 +0000

[ multipart/encrypted ]
[ Decryption successful ]
[ application/pgp-encrypted ]
[ text/plain ]
This is the sekrit message
EOF
test_expect_equal_file EXPECTED OUTPUT

# notmuch-emacs still leaks the subject line; as long as it leaks the
# subject line, it should emit the external subject, not the protected
# subject, even if it knows what the true subject is:
test_begin_subtest "Reply within emacs to a message with protected headers, not leaking subject"
test_emacs "(let ((message-hidden-headers '()))
	    (notmuch-show \"id:protected-header@crypto.notmuchmail.org\")
	    (notmuch-show-reply)
	    (test-output))"
cat <<EOF >EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: test_suite@notmuchmail.org
Subject: Re: Subject Unavailable
In-Reply-To: <protected-header@crypto.notmuchmail.org>
Fcc: ${MAIL_DIR}/sent
References: <protected-header@crypto.notmuchmail.org>
--text follows this line--
<#secure method=pgpmime mode=signencrypt>
test_suite@notmuchmail.org writes:

> This is the sekrit message
EOF
test_expect_equal_file EXPECTED OUTPUT

# protected headers should behave differently after re-indexing
test_begin_subtest 'defaulting to indexing cleartext'
test_expect_success 'notmuch config set index.decrypt true'
test_begin_subtest 'try reindexing protected header message'
test_expect_success 'notmuch reindex id:protected-header@crypto.notmuchmail.org'

test_begin_subtest "notmuch-search should show indexed protected subject header in emacs"
test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
	    (notmuch-test-wait)
	    (test-output)'
cat <<EOF >EXPECTED
  2000-01-01 [1/1]   test_suite@notmuchmail.org  This is a protected header (encrypted inbox)
End of search results.
EOF
test_expect_equal_file EXPECTED OUTPUT

# notmuch-emacs still leaks the subject line:
test_begin_subtest "don't leak protected subject during reply, even if indexed"
test_emacs "(let ((message-hidden-headers '()))
	    (notmuch-show \"id:protected-header@crypto.notmuchmail.org\")
	    (notmuch-show-reply)
	    (test-output))"
cat <<EOF >EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org>
To: test_suite@notmuchmail.org
Subject: Re: Subject Unavailable
In-Reply-To: <protected-header@crypto.notmuchmail.org>
Fcc: ${MAIL_DIR}/sent
References: <protected-header@crypto.notmuchmail.org>
--text follows this line--
<#secure method=pgpmime mode=signencrypt>
test_suite@notmuchmail.org writes:

> This is the sekrit message
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving b296a9c5 ...
found b296a9c5 in https://yhetil.org/notmuch/20210522152741.27213-1-tomi.ollila@iki.fi/ ||
	https://yhetil.org/notmuch/20210523073443.11618-1-tomi.ollila@iki.fi/
found b25d7ea7 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 b25d7ea79e4626950b89fcb2893da195d9f3da92	test/T358-emacs-protected-headers.sh

applying [1/1] https://yhetil.org/notmuch/20210522152741.27213-1-tomi.ollila@iki.fi/
diff --git a/test/T358-emacs-protected-headers.sh b/test/T358-emacs-protected-headers.sh
index b25d7ea7..b296a9c5 100755

Checking patch test/T358-emacs-protected-headers.sh...
Applied patch test/T358-emacs-protected-headers.sh cleanly.

skipping https://yhetil.org/notmuch/20210523073443.11618-1-tomi.ollila@iki.fi/ for b296a9c5
index at:
100755 b296a9c59f5a422df6e23e603db060021412f193	test/T358-emacs-protected-headers.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).