]> git.notmuchmail.org Git - notmuch/blob - test/T358-emacs-protected-headers.sh
test: emacs/show: ensure that protected headers appear as expected
[notmuch] / test / T358-emacs-protected-headers.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 # testing protected headers with emacs
7 add_gnupg_home
8 add_email_corpus protected-headers
9
10 test_begin_subtest "notmuch-search should show not unindexed protected subject header in emacs"
11 test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
12             (notmuch-test-wait)
13             (test-output)'
14 cat <<EOF >EXPECTED
15   2000-01-01 [1/1]   test_suite@notmuchmail.org  Subject Unavailable (encrypted inbox unread)
16 End of search results.
17 EOF
18 test_expect_equal_file EXPECTED OUTPUT
19
20 test_begin_subtest "notmuch-show should not show unindexed protected subject header in emacs when nm-c-process-mime is nil"
21 test_emacs '(let ((notmuch-crypto-process-mime nil))
22              (notmuch-show "id:protected-header@crypto.notmuchmail.org")
23              (test-output))'
24 cat <<EOF >EXPECTED
25 test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
26 Subject: Subject Unavailable
27 To: test_suite@notmuchmail.org
28 Date: Sat, 01 Jan 2000 12:00:00 +0000
29
30 [ multipart/encrypted ]
31 [ Unknown encryption status ]
32 [ application/pgp-encrypted ]
33 [ application/octet-stream ]
34 EOF
35 test_expect_equal_file EXPECTED OUTPUT
36
37 test_begin_subtest "notmuch-show should show protected subject header in emacs"
38 test_emacs '(notmuch-show "id:protected-header@crypto.notmuchmail.org")
39             (test-output)'
40 cat <<EOF >EXPECTED
41 test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
42 Subject: This is a protected header
43 To: test_suite@notmuchmail.org
44 Date: Sat, 01 Jan 2000 12:00:00 +0000
45
46 [ multipart/encrypted ]
47 [ Decryption successful ]
48 [ application/pgp-encrypted ]
49 [ text/plain ]
50 This is the sekrit message
51 EOF
52 test_expect_equal_file EXPECTED OUTPUT
53
54 # protected headers should behave differently after re-indexing
55 test_begin_subtest 'defaulting to indexing cleartext'
56 test_expect_success 'notmuch config set index.decrypt true'
57 test_begin_subtest 'try reindexing protected header message'
58 test_expect_success 'notmuch reindex id:protected-header@crypto.notmuchmail.org'
59
60 test_begin_subtest "notmuch-search should show indexed protected subject header in emacs"
61 test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
62             (notmuch-test-wait)
63             (test-output)'
64 cat <<EOF >EXPECTED
65   2000-01-01 [1/1]   test_suite@notmuchmail.org  This is a protected header (encrypted inbox)
66 End of search results.
67 EOF
68 test_expect_equal_file EXPECTED OUTPUT
69
70 test_done