aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brunschwig <[email protected]>2021-05-02 18:48:21 +0200
committerPatrick Brunschwig <[email protected]>2021-05-02 18:48:21 +0200
commitdb5e33890b2d93ce6ef260e459d109df1fa99567 (patch)
treedce6c125e8426adf56777f43db20b4ae262111dc
parentba19479df4035ab618ad67f971c25b645568a887 (diff)
downloadenigmail-db5e33890b2d93ce6ef260e459d109df1fa99567.tar.gz
enigmail-db5e33890b2d93ce6ef260e459d109df1fa99567.tar.bz2
enigmail-db5e33890b2d93ce6ef260e459d109df1fa99567.zip
use promises instead of do_test_pending
-rw-r--r--package/tests/keyEditor-test.js176
-rwxr-xr-xprovisioning/wine-setup.sh1
2 files changed, 91 insertions, 86 deletions
diff --git a/package/tests/keyEditor-test.js b/package/tests/keyEditor-test.js
index ddd56abf..88b527ad 100644
--- a/package/tests/keyEditor-test.js
+++ b/package/tests/keyEditor-test.js
@@ -1,5 +1,5 @@
-/*global do_load_module: false, do_get_file: false, do_get_cwd: false, testing: false, test: false, Assert: false, resetting: false, JSUnit: false, do_test_pending: false, do_test_finished: false, withTestGpgHome:false */
-/*global Ec: false, do_print: false, EnigmailCore: false, EnigmailKeyEditor: false, component: false, EnigmailPrefs: false, EnigmailExecution: false */
+/*global do_load_module: false, do_get_file: false, do_get_cwd: false, testing: false, test: false, Assert: false, resetting: false, JSUnit: false, withTestGpgHome:false */
+/*global Ec: false, asyncTest: false, do_print: false, EnigmailCore: false, EnigmailKeyEditor: false, component: false, EnigmailPrefs: false, EnigmailExecution: false */
/*
* 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
@@ -13,96 +13,103 @@ do_load_module("file://" + do_get_cwd().path + "/testHelper.js"); /*global withE
testing("cryptoAPI/gnupg-keyEditor.jsm"); /*global editKey: false, EnigmailKeyRing: false */
var EnigmailTime = component("enigmail/time.jsm").EnigmailTime;
-test(withTestGpgHome(withEnigmail(function shouldEditKey() {
- importKeys();
- do_test_pending();
- var window = JSUnit.createStubWindow();
- editKey(
- window,
- false,
- null,
- "781617319CE311C4",
- "trust", {
- trustLevel: 5
- },
- function(inputData, keyEdit, ret) {
- ret.writeTxt = "";
- ret.errorMsg = "";
- ret.quitNow = true;
- ret.exitCode = 0;
- },
- null,
- function(exitCode, errorMsg) {
- Assert.equal(exitCode, 0);
- Assert.equal("", errorMsg);
- do_test_finished();
- }
- );
-})));
-
-test(withTestGpgHome(withEnigmail(function shouldSetTrust() {
- importKeys();
- do_test_pending();
- var window = JSUnit.createStubWindow();
- EnigmailKeyEditor.setKeyTrust(window, "781617319CE311C4", 5).then(
- resultObj => {
- Assert.equal(resultObj.returnCode, 0);
- Assert.equal("", resultObj.errorMsg);
- do_test_finished();
+test(withTestGpgHome(withEnigmail(asyncTest(function shouldEditKey() {
+ return new Promise((resolve, reject) => {
+ importKeys();
+ var window = JSUnit.createStubWindow();
+ editKey(
+ window,
+ false,
+ null,
+ "781617319CE311C4",
+ "trust", {
+ trustLevel: 5
+ },
+ function(inputData, keyEdit, ret) {
+ ret.writeTxt = "";
+ ret.errorMsg = "";
+ ret.quitNow = true;
+ ret.exitCode = 0;
+ },
+ null,
+ function(exitCode, errorMsg) {
+ Assert.equal(exitCode, 0);
+ Assert.equal("", errorMsg);
+ resolve(1);
+ }
+ );
+ });
+}))));
+
+test(withTestGpgHome(withEnigmail(asyncTest(function shouldSetTrust() {
+ return new Promise((resolve, reject) => {
+ importKeys();
+ var window = JSUnit.createStubWindow();
+ EnigmailKeyEditor.setKeyTrust(window, "781617319CE311C4", 5).then(
+ resultObj => {
+ Assert.equal(resultObj.returnCode, 0);
+ Assert.equal("", resultObj.errorMsg);
+ resolve(true);
+ });
+ });
+}))));
+
+test(withTestGpgHome(withEnigmail(asyncTest(function shouldSignKey() {
+ return new Promise((resolve, reject) => {
+ importKeys();
+ var window = JSUnit.createStubWindow();
+ EnigmailKeyEditor.signKey(window,
+ "0x65537E212DC19025AD38EDB2781617319CE311C4",
+ "781617319CE311C4",
+ ["anonymous strike <[email protected]>"],
+ false,
+ 5
+ ).then(resultObj => {
+ Assert.equal(resultObj.returnCode, -1);
+ Assert.equal("The key is already signed, you cannot sign it twice.", resultObj.errorMsg);
+ resolve(true);
+ }).catch(err => {
+ Assert.ok(false, `Error: ${err}`);
+ resolve(true);
});
-})));
-
-test(withTestGpgHome(withEnigmail(function shouldSignKey() {
- importKeys();
- do_test_pending();
- var window = JSUnit.createStubWindow();
- EnigmailKeyEditor.signKey(window,
- "0x65537E212DC19025AD38EDB2781617319CE311C4",
- "781617319CE311C4",
- ["anonymous strike <[email protected]>"],
- false,
- 5
- ).then(resultObj => {
- Assert.equal(resultObj.returnCode, -1);
- Assert.equal("The key is already signed, you cannot sign it twice.", resultObj.errorMsg);
- do_test_finished();
});
-})));
+}))));
-test(withTestGpgHome(function importKeyForEdit() {
+test(withTestGpgHome(withEnigmail(function importKeyForEdit() {
const result = importKeys();
Assert.equal(result[0], 0);
Assert.equal(result[1], 0);
-}));
-
-
-test(withTestGpgHome(withEnigmail(function shouldGetSecretKeys() {
- const secretKey = do_get_file("resources/dev-strike.sec", false);
- const errorMsgObj = {};
- const importedKeysObj = {};
- const window = JSUnit.createStubWindow();
- const importResult = EnigmailKeyRing.importKeyFromFile(secretKey, errorMsgObj, importedKeysObj);
+})));
- const createDate = EnigmailTime.getDateTime(1430756251, true, false);
- const expectedKey = [{
- userId: "anonymous strike <[email protected]>",
- keyId: "781617319CE311C4",
- created: createDate,
- keyTrust: "u"
- }];
- do_test_pending();
- EnigmailKeyEditor.setKeyTrust(window, "781617319CE311C4", 5).then(
- resultObj => {
- let result = EnigmailKeyRing.getAllSecretKeys();
- Assert.equal(result.length, 1);
- Assert.equal(result[0].userId, expectedKey[0].userId);
- Assert.equal(result[0].keyId, expectedKey[0].keyId);
- Assert.equal(result[0].created, expectedKey[0].created);
- Assert.equal(result[0].keyTrust, expectedKey[0].keyTrust);
- do_test_finished();
- });
-})));
+test(withTestGpgHome(withEnigmail(asyncTest(function shouldGetSecretKeys() {
+ return new Promise((resolve, reject) => {
+ const secretKey = do_get_file("resources/dev-strike.sec", false);
+ const errorMsgObj = {};
+ const importedKeysObj = {};
+ const window = JSUnit.createStubWindow();
+ const importResult = EnigmailKeyRing.importKeyFromFile(secretKey, errorMsgObj, importedKeysObj);
+
+ const createDate = EnigmailTime.getDateTime(1430756251, true, false);
+
+ const expectedKey = [{
+ userId: "anonymous strike <[email protected]>",
+ keyId: "781617319CE311C4",
+ created: createDate,
+ keyTrust: "u"
+ }];
+ EnigmailKeyEditor.setKeyTrust(window, "781617319CE311C4", 5).then(
+ resultObj => {
+ let result = EnigmailKeyRing.getAllSecretKeys();
+ Assert.equal(result.length, 1);
+ Assert.equal(result[0].userId, expectedKey[0].userId);
+ Assert.equal(result[0].keyId, expectedKey[0].keyId);
+ Assert.equal(result[0].created, expectedKey[0].created);
+ Assert.equal(result[0].keyTrust, expectedKey[0].keyTrust);
+ resolve(1);
+ });
+ });
+}))));
test(function shouldDoErrorHandling() {
let nextCmd = "";
@@ -118,7 +125,6 @@ test(function shouldDoErrorHandling() {
editor.gotData("[GNUPG:] FAILURE sign 85\n");
Assert.ok(editor.errorMsg.length > 0);
Assert.equal("save\n", nextCmd);
-
});
function importKeys() {
diff --git a/provisioning/wine-setup.sh b/provisioning/wine-setup.sh
index 4762cc46..c8680c28 100755
--- a/provisioning/wine-setup.sh
+++ b/provisioning/wine-setup.sh
@@ -31,7 +31,6 @@ user_pref("extensions.enigmail.logDirectory", "C:\\Enigmail\\test-profile");
user_pref("extensions.enigmail.juniorMode", 0);
user_pref("extensions.enigmail.pEpAutoDownload", false);
user_pref("extensions.enigmail.configuredVersion", "99.0");
-user_pref("extensions.enigmail.keyRefreshOn", false);
user_pref("devtools.debugger.prompt-connection", false);
user_pref("mail.account.account1.identities", "id1");
user_pref("mail.account.account1.server", "server2");