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
| | #!/usr/bin/env bash
test_description='Decryption of inline PGP messages'
. $(dirname "$0")/test-lib.sh || exit 1
##################################################
add_gnupg_home
test_begin_subtest "Adding inline PGP encrypted message"
mkdir -p "$MAIL_DIR/cur"
cat <<EOF > "$MAIL_DIR/cur/inline-pgp-encrypted.eml"
Message-Id: inline-pgp-encrypted@testsuite.notmuchmail.org
Content-Type: text/plain
Subject: inline PGP encrypted message
Date: Sat, 01 Jan 2000 12:00:00 +0000
From: test_suite@notmuchmail.org
To: test_suite@notmuchmail.org
$(echo "this is the sekrit message" | gpg --no-tty --batch --quiet --trust-model=always --encrypt --armor --recipient test_suite@notmuchmail.org)
EOF
test_expect_success 'notmuch new'
test_begin_subtest "inline PGP decryption, --format=json"
test_subtest_broken_gmime_2
output=$(notmuch show --format=json --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org \
| notmuch_json_show_sanitize)
expected='
[[[{"body": [{
"content": "this is the sekrit message\n",
"content-type": "text/plain",
"encstatus": [{"status": "good" }],
"id": 1
}],
"date_relative": "2000-01-01",
"excluded": false,
"filename": ["YYYYY"],
"headers": {
"Date": "Sat, 01 Jan 2000 12:00:00 +0000",
"From": "test_suite@notmuchmail.org",
"Subject": "inline PGP encrypted message",
"To": "test_suite@notmuchmail.org"
},
"id": "XXXXX",
"match": true,
"tags": ["encrypted", "inbox", "unread"],
"timestamp": 946728000
},
[]]]]'
test_expect_equal_json \
"$output" \
"$expected"
test_begin_subtest "inline PGP decryption for reply"
test_subtest_broken_gmime_2
output=$(notmuch reply --format=json --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org \
| notmuch_json_show_sanitize)
expected='
{"original": {"body": [{
"content": "this is the sekrit message\n",
"content-type": "text/plain",
"encstatus": [{"status": "good" }],
"id": 1
}],
"date_relative": "2000-01-01",
"excluded": false,
"filename": ["YYYYY"],
"headers": {
"Date": "Sat, 01 Jan 2000 12:00:00 +0000",
"From": "test_suite@notmuchmail.org",
"Subject": "inline PGP encrypted message",
"To": "test_suite@notmuchmail.org"
},
"id": "XXXXX",
"match": false,
"tags": ["encrypted", "inbox", "unread"],
"timestamp": 946728000
},
"reply-headers": {
"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
"In-reply-to": "<inline-pgp-encrypted@testsuite.notmuchmail.org>",
"References": "<inline-pgp-encrypted@testsuite.notmuchmail.org>",
"Subject": "Re: inline PGP encrypted message"
}
}'
test_expect_equal_json \
"$output" \
"$expected"
test_begin_subtest "searching for cleartext of inline PGP encrypted message should fail"
output=$(notmuch search 'sekrit')
expected=''
test_expect_equal "$output" "$expected"
test_begin_subtest "reindexing cleartext of inline PGP encrypted message should succeed"
test_subtest_broken_gmime_2
notmuch reindex --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org
output=$(notmuch search 'sekrit')
expected='thread:0000000000000001 2000-01-01 [1/1] test_suite@notmuchmail.org; inline PGP encrypted message (encrypted inbox unread)'
test_expect_equal "$output" "$expected"
test_done
|