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
117
118
119
120
121
122
123
124
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Tests for the display of OpenPGP signed/encrypted state in opened messages,
* when OpenPGP passphrases are in use.
*/
"use strict";
const { get_about_message, open_message_from_file } = ChromeUtils.import(
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
const { close_window } = ChromeUtils.import(
"resource://testing-common/mozmill/WindowHelpers.jsm"
);
const { waitForCondition } = ChromeUtils.import(
"resource://testing-common/mozmill/utils.jsm"
);
const { OpenPGPTestUtils } = ChromeUtils.import(
"resource://testing-common/mozmill/OpenPGPTestUtils.jsm"
);
const { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
const MSG_TEXT = "Sundays are nothing without callaloo.";
function getMsgBodyTxt(mc) {
let msgPane = get_about_message(mc.window).getMessagePaneBrowser();
return msgPane.contentDocument.documentElement.textContent;
}
var aliceAcct;
/**
* Set up the base account, identity and keys needed for the tests.
*/
add_setup(async function () {
aliceAcct = MailServices.accounts.createAccount();
aliceAcct.incomingServer = MailServices.accounts.createIncomingServer(
"alice",
"openpgp.example",
"pop3"
);
let aliceIdentity = MailServices.accounts.createIdentity();
aliceIdentity.email = "alice@openpgp.example";
aliceAcct.addIdentity(aliceIdentity);
// Set up the alice's private key, which has a passphrase set
let [id] = await OpenPGPTestUtils.importPrivateKey(
window,
new FileUtils.File(
getTestFilePath(
"data/keys/alice@openpgp.example-0xf231550c4f47e38e-secret-with-pp.asc"
)
),
OpenPGPTestUtils.ACCEPTANCE_PERSONAL,
"alice-passphrase",
true
);
aliceIdentity.setUnicharAttribute("openpgp_key_id", id);
// Import and accept the public key for Bob, our verified sender.
await OpenPGPTestUtils.importPublicKey(
window,
new FileUtils.File(
getTestFilePath(
"data/keys/bob@openpgp.example-0xfbfcc82a015e7330-pub.asc"
)
)
);
});
/**
* Test that opening an unsigned encrypted message shows as such.
*/
add_task(async function testOpenVerifiedUnsignedEncrypted2() {
let passPromptPromise = BrowserTestUtils.promiseAlertDialogOpen();
let openMessagePromise = open_message_from_file(
new FileUtils.File(
getTestFilePath(
"data/eml/unsigned-encrypted-to-0xf231550c4f47e38e-from-0xfbfcc82a015e7330.eml"
)
)
);
let ppWin = await passPromptPromise;
// We'll enter a wrong pp, so we expect another prompt
let passPromptPromise2 = BrowserTestUtils.promiseAlertDialogOpen();
ppWin.document.getElementById("password1Textbox").value = "WRONG-passphrase";
ppWin.document.querySelector("dialog").getButton("accept").click();
let ppWin2 = await passPromptPromise2;
ppWin2.document.getElementById("password1Textbox").value = "alice-passphrase";
ppWin2.document.querySelector("dialog").getButton("accept").click();
let mc = await openMessagePromise;
let aboutMessage = get_about_message(mc.window);
Assert.ok(getMsgBodyTxt(mc).includes(MSG_TEXT), "message text is in body");
Assert.ok(
OpenPGPTestUtils.hasNoSignedIconState(aboutMessage.document),
"signed icon is not displayed"
);
Assert.ok(
OpenPGPTestUtils.hasEncryptedIconState(aboutMessage.document, "ok"),
"encrypted icon is displayed"
);
close_window(mc);
});
registerCleanupFunction(async function tearDown() {
MailServices.accounts.removeAccount(aliceAcct, true);
await OpenPGPTestUtils.removeKeyById("0xf231550c4f47e38e", true);
});
|