Bug 1152287: Permafail of crypto mozmill test, r=rkent, a=rkent THUNDERBIRD_38_VERBRANCH
authorJoshua Cranmer <Pidgeot18@gmail.com>
Wed, 15 Apr 2015 09:31:28 -0500
branchTHUNDERBIRD_38_VERBRANCH
changeset 26031 f902a0828c710c7e5a82772b687dd6b75d40af00
parent 26029 8f043730a279642fa6392bab2dc2b052215b02e8
child 26033 25a8ebdef34bae908dd1ef0882030e1e978a6f94
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs1152287
Bug 1152287: Permafail of crypto mozmill test, r=rkent, a=rkent
mail/test/mozmill/crypto/test-smime-mimemsg-representation.js
mail/test/mozmill/crypto/wrapper.py
mail/test/mozmill/mozmilltests.list
mailnews/db/gloda/test/unit/test_smime_mimemsg_representation.js
mailnews/db/gloda/test/unit/xpcshell.ini
deleted file mode 100644
--- a/mail/test/mozmill/crypto/wrapper.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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/.
-
-# We install db files with the necessary preloaded certs to run tests that
-# involve S/MIME.
-
-import os, shutil, sys
-
-def on_profile_created(profile):
-  """
-  This installs the db files into the profile so that we can test out stuff
-  such as S/MIME.
-  """
-
-  data_path = os.path.join(os.path.dirname(__file__),
-                           "../../../../mailnews/test/data/db-tinderbox-invalid")
-  if not os.path.exists(data_path):
-    data_path = os.path.join(os.path.dirname(__file__),
-                             "../../xpcshell/tests/mailnews/data/db-tinderbox-invalid")
-    if not os.path.exists(data_path):
-      sys.exit("TEST-UNEXPECTED-FAIL | crypto | Failed to find the appropraite data_path")
-
-  db_files = ["cert8.db", "key3.db", "secmod.db"]
-
-  for f in db_files:
-    shutil.copy(os.path.join(data_path, f), profile)
--- a/mail/test/mozmill/mozmilltests.list
+++ b/mail/test/mozmill/mozmilltests.list
@@ -1,17 +1,16 @@
 account
 addrbook
 attachment
 cloudfile
 composition
 content-policy
 content-tabs
 cookies
-crypto
 downloads
 folder-display
 folder-pane
 folder-tree-modes
 folder-widget
 im
 instrumentation
 junk-commands
rename from mail/test/mozmill/crypto/test-smime-mimemsg-representation.js
rename to mailnews/db/gloda/test/unit/test_smime_mimemsg_representation.js
--- a/mail/test/mozmill/crypto/test-smime-mimemsg-representation.js
+++ b/mailnews/db/gloda/test/unit/test_smime_mimemsg_representation.js
@@ -1,74 +1,101 @@
 /* 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/. */
 
 /*
  * Test that S/MIME messages are properly displayed and that the MimeMessage
  * representation is correct.
  */
-var MODULE_NAME = "test-display-smime";
+load("../../../../resources/logHelper.js");
+load("../../../../resources/asyncTestUtils.js");
 
-var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = ["folder-display-helpers", "message-helpers"];
+load("../../../../resources/messageGenerator.js");
+load("../../../../resources/messageModifier.js");
+load("../../../../resources/messageInjection.js");
 
-var folder;
+const msgGen = gMessageGenerator = new MessageGenerator();
+
+Components.utils.import("resource:///modules/FileUtils.jsm");
+Components.utils.import("resource:///modules/gloda/mimemsg.js");
 
-function setupModule(module) {
-  let fdh = collector.getModule("folder-display-helpers");
-  fdh.installInto(module);
-  let mh = collector.getModule("message-helpers");
-  mh.installInto(module);
+function initNSS() {
+  // Copy the NSS database files over.
+  let profile = FileUtils.getDir("ProfD", []);
+  let files = ['cert8.db', 'key3.db', 'secmod.db'];
+  let directory = do_get_file("../../../../data/db-tinderbox-invalid");
+  for (let f of files) {
+    let keydb = directory.clone();
+    keydb.append(f);
+    keydb.copyTo(profile, f);
+  }
 
-  folder = create_folder("SMIME_A");
+  // Ensure NSS is initialized.
+  Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports);
+}
 
-  let msg = create_encrypted_smime_message({
+var gInbox;
+function test_smime_mimemsg() {
+  let msg = msgGen.makeEncryptedSMimeMessage({
     from: ["Tinderbox", "tinderbox@foo.invalid"],
     to: [["Tinderbox", "tinderbox@foo.invalid"]],
     subject: "Albertine disparue (La Fugitive)",
     body: { body: encrypted_blurb },
   });
-  add_message_to_folder(folder, msg);
-}
+  let synSet = new SyntheticMessageSet([msg]);
+  yield add_sets_to_folder(gInbox, [synSet]);
 
-function test_smime_mimemsg() {
-  be_in_folder(folder);
-  let msgHdr = select_click_row(0);
+  let msgHdr = synSet.getMsgHdr(0);
 
   // Make sure by default, MimeMessages do not include encrypted parts
-  to_mime_message(msgHdr, null, function(aMsgHdr, aMimeMsg) {
+  MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
     // First make sure the MIME structure is as we expect it to be.
-    assert_equals(aMimeMsg.parts.length, 1);
+    do_check_eq(aMimeMsg.parts.length, 1);
     // Then, make sure the MimeUnknown part there has the encrypted flag
-    assert_true(aMimeMsg.parts[0].isEncrypted);
+    do_check_true(aMimeMsg.parts[0].isEncrypted);
     // And that we can't "see through" the MimeUnknown container
-    assert_equals(aMimeMsg.parts[0].parts.length, 0);
+    do_check_eq(aMimeMsg.parts[0].parts.length, 0);
     // Make sure we can't see the attachment
-    assert_equals(aMimeMsg.allUserAttachments.length, 0);
+    do_check_eq(aMimeMsg.allUserAttachments.length, 0);
+    async_driver();
   }, true, {
   });
 
+  yield false;
+
   // Now what about we specifically ask to "see" the encrypted parts?
-  to_mime_message(msgHdr, null, function(aMsgHdr, aMimeMsg) {
+  MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
     // First make sure the MIME structure is as we expect it to be.
-    assert_equals(aMimeMsg.parts.length, 1);
+    do_check_eq(aMimeMsg.parts.length, 1);
     // Then, make sure the MimeUnknown part there has the encrypted flag
-    assert_true(aMimeMsg.parts[0].isEncrypted);
+    do_check_true(aMimeMsg.parts[0].isEncrypted);
     // And that we can "see through" the MimeUnknown container
-    assert_equals(aMimeMsg.parts[0].parts.length, 1);
-    assert_equals(aMimeMsg.parts[0].parts[0].parts.length, 1);
-    assert_equals(aMimeMsg.parts[0].parts[0].parts[0].parts.length, 2);
+    do_check_eq(aMimeMsg.parts[0].parts.length, 1);
+    do_check_eq(aMimeMsg.parts[0].parts[0].parts.length, 1);
+    do_check_eq(aMimeMsg.parts[0].parts[0].parts[0].parts.length, 2);
     // Make sure we can see the attachment
-    assert_equals(aMimeMsg.allUserAttachments.length, 1);
-    assert_equals(aMimeMsg.allUserAttachments[0].contentType, "image/jpeg");
+    do_check_eq(aMimeMsg.allUserAttachments.length, 1);
+    do_check_eq(aMimeMsg.allUserAttachments[0].contentType, "image/jpeg");
+    async_driver();
     // Extra little bit of testing
   }, true, {
     examineEncryptedParts: true,
   });
+  yield false;
+}
+
+var tests = [
+  test_smime_mimemsg,
+];
+
+function run_test() {
+  initNSS();
+  gInbox = configure_message_injection({mode: "local"});
+  async_run_tests(tests);
 }
 
 var encrypted_blurb =
   "MIAGCSqGSIb3DQEHA6CAMIACAQAxgf8wgfwCAQAwZTBgMQswCQYDVQQGEwJTVzETMBEGA1UE\n"+
   "CBMKVGVzdCBTdGF0ZTERMA8GA1UEBxMIVGVzdCBMb2MxETAPBgNVBAoTCFRlc3QgT3JnMRYw\n"+
   "FAYDVQQDEw1TTUlNRSBUZXN0IENBAgEFMA0GCSqGSIb3DQEBAQUABIGAJ6gUwBMmtiIIF4ii\n"+
   "SzkMP5vh6kCztLuF7yy/To27ZUlNOjBZZRuiwcQHiZx0aZXVhtAZcLgQKRcDwwGGd0xGvBIW\n"+
   "dHO/gJlVX0frePMALZx/NIUtbN1cjtwDAezcTmTshiosYmlzzpPnTkgPDNDezxbN4bdBfWRu\n"+
--- a/mailnews/db/gloda/test/unit/xpcshell.ini
+++ b/mailnews/db/gloda/test/unit/xpcshell.ini
@@ -28,9 +28,10 @@ support-files = base_*.js resources/*
 [test_noun_mimetype.js]
 [test_nuke_migration.js]
 [test_nuke_migration_from_future.js]
 [test_query_core.js]
 [test_query_messages_imap_offline.js]
 [test_query_messages_imap_online.js]
 [test_query_messages_imap_online_to_offline.js]
 [test_query_messages_local.js]
+[test_smime_mimemsg_representation.js]
 [test_startup_offline.js]